rod mclaughlin


Moving to Rails 3 (16 may 10)

Rails 3 is out

Contra the instructions, you don't want Ruby 1.9.2 - Rails 3 can crash it. You want Ruby 1.8.7 - on Linux,  do this first -

sudo apt-get install libncurses5-dev 
sudo apt-get install libreadline5-dev

Then download Ruby from

http://www.ruby-lang.org/en/news/2010/08/16/ruby-1-8-7-p302-is-released/

bunzip2 ruby...tar.bz2
tar xvf ruby...tar
cd ruby-.../ext/readline
ruby extconf.rb
make
cd ../..
./configure ; make ; sudo make install
cd ..

Get sqlite-amalgamation-3.6.23.1.tar.gz from wherever you can find it on the web

tar xvfz sqlite-amalgamation-3.6.23.1.tar.gz
cd sqlite-3.6.23.1
./configure ; make ; sudo make install
cd ..
sudo gem update --system
sudo gem install tzinfo builder memcache-client rack rack-test rack-mount 
sudo gem install erubis mail text-format thor bundler i18n
sudo gem install sqlite3
sudo gem install sqlite3-ruby

Create a file called 'Gemfile' in your Rails project root and put this in it:

source 'http://rubygems.org'
gem 'rails', '3.0.0'
gem 'hpricot', '0.8.2'
gem "will_paginate", "~> 3.0.pre2"
gem 'sqlite3-ruby', :require => 'sqlite3'
gem 'libxml-ruby'
gem 'authlogic'
gem 'dynamic_form'

then enter 'bundle' from the command line

Now the fun part...

Rails 3 won't run your existing Rails Apps without several changes

For example, you don't type 'script/server' to start, you type 'rails server'

http://pdxspurs.com


 

I had to remove 'observe_form' AJAX generators in my edit.htm.erb files: this doesn't work any more:

      <%= observe_form( "edit_post_#{@post.id.to_s}",
                        :frequency => 30.0,
                        :update => 'message_message',
                        :url => { :action => :save, :id => @post.id.to_s } ) %> 

If you had

<%= @post.message %>

in an erb file in views, you now have

<%= raw( @post.message ) %>

and h( @post.title ) is no longer necessary

just

<%= @post.title %>


There used to be a handy little tool for adding user login, passwords etc. to Rails called 'acts_as_authenticated'. Then they stopped supporting it, and it is incompatible with Rails 3. Instead, there  is a plethora of badly-documented alternatives, which are apparently more 'restful', etc., and are harder to install, use, or understand. The one I'm trying to get into is called 'authlogic': http://github.com/binarylogic/authlogic_example

 



Back
Portland London