Rod McLaughlin


Moving to Rails 3

 

Rails 3 beta pre-relase cantidate is out

Get ruby 1.9

tar xvfz ruby-1.9.1-p376.tar.gz from ftp://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.1-p376.tar.gz

cd ruby-1.9.1-p376

./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 rails --pre 
sudo gem install sqlite3
sudo gem install sqlite3-ruby

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'

I found that, although I had installed sqlite3 from source, and the Ruby gems sqlite3 and sqlite3-ruby, Rails couldn't find gem sqlite3

Since the process of installing this 'lite' version of sql is harder than installing MySQL, I

a. Changed all references to sqlite3 in my config/database.yml file to refer to mysql instead, and

b. Commented out the sqlite3 reference in my Gemfile, like this:

# gem 'sqlite3-ruby', :require => 'sqlite3'

Then I found typing 'rails server' just about got the thing started.

I could point my browser at http://localhost:3000 and see a website.

Here is a collection of notes on how to get started with Rails 3:

http://www.rubyinside.com/rails-3-0-beta-links-2966.html

I will add more stuff here about what I had to do to port my Rails 2 site, http://pdxspurs.com, to Rails 3


First, I found will_paginate didn't work any more

I got rid of references to will_paginate and made my posts_controller do this:      

    @posts = Post.find( :all,
            :order => sort_order('id'), :conditions => 'post_id is null' ) 

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 %>


Eventually, when all else failed, I read the instructions:

http://omgbloglol.com/post/371893012/the-path-to-rails-3-greenfielding-new-apps-with-the

What you have to do, before running 'rails server', edit Gemfile, and add gems, like so:

source 'http://rubygems.org'
gem 'rails', '3.0.0.beta3'
gem 'hpricot', '0.8.2'

then run 'sudo bundle install'

then 'rails server'

 



Back