Blog

April 06 2009

Rails 2.3.2 and Other Configuration Changesby railsdog

I recently finished updating the spree-demo project to use the latest code. It reminded me that there were several small required configuration changes that you should be aware of if you’re trying to upgrade an existing app.

The first thing to do is change the rails version in config/boot.rb from Rails 2.2.2 to Rails 2.3.2 by replacing


load_rails("~>2.2.2")  # note: spree requires rails 2.2.2 (change at your own risk)

with


load_rails("2.3.2")  # note: spree requires rails 2.3.2 (change at your own risk)

The next step is to map the new resources and routes in config/routes.rb. Start by removing the old login routes below


map.login '/login', :controller => 'account', :action => 'login'
map.logout '/logout', :controller => 'account', :action => 'logout'
map.signup '/signup', :controller => 'users', :action => 'new'
map.admin '/admin', :controller => 'admin/overview', :action => 'index'

and replace with these lines:


map.resource :user_session
map.resource :account, :controller => "users"
map.resources :password_resets
# login mappings should appear before all others
map.login '/login', :controller => 'user_sessions', :action => 'new'
map.logout '/logout', :controller => 'user_sessions', :action => 'destroy'
map.signup '/signup', :controller => 'users', :action => 'new'
map.admin '/admin', :controller => 'admin/overview', :action => 'index'

You’ll also want to make sure that your config/environment.rb file contains exactly these entries:


config.gem "highline", :version => '1.4.0'
config.gem 'authlogic', :version => '2.0.5'
config.gem "activemerchant", :lib => "active_merchant", :version => '1.4.1'
config.gem "tlsmail", :version => '0.0.1'
config.gem 'active_presenter', :version => '0.0.6'
config.gem 'activerecord-tableless', :lib => 'tableless', :version => '0.1.0'
config.gem 'calendar_date_select', :version => '1.15'
config.gem 'haml', :version => '2.1.0'
config.gem 'chriseppstein-compass', :lib => 'compass', :version => '0.5.4'
# HACKED version of search logic - we'll move back when our fix is accepted into core
config.gem 'schof-searchlogic', :lib => 'searchlogic', :version => '0.0.2'  

The authlogic gem version has been incremented (and is likely to increment again because of bug fixes.) The calendar_date_select plugin has been removed and replaced with a gem (so you will need to install that.) The has_many_polymoprhs gem has been removed entirely because of problems getting it to work in Rails 2.3. You’ll also need the haml and compass gems listed above. The haml gem needs to be built from source (in GitHub) and the compass gem is available in GitHub’s gem repository. Both gems are also “vendored” in the edge source if you wanted to copy them into a current deployment.

If you are working on a brand new project using the edge Spree code, none of these steps should be necessary. This is just to help you get an existing Spree deployment up and running.