This post originated from an RSS feed registered with Ruby Buzz
by Nathaniel Brown.
Original Post: Engines 2.0 and Rails 2.0 Upgrade Gotchas
Feed Title: Nathaniel Brown
Feed URL: http://feeds.feedburner.com/nshb
Feed Description: Insight as a professional Technology Consltant and Photographer.
Adding some new session config options to your environment.rb as well:
config.action_controller.session = {
:session_key => '_www_example_com-trunk_session',
:secret => 'Long string for security. Run "rake secret" to generate'
}
Utilization of the new /config/initializers to be used on load (optional). Use these for plugin or namespaced configuration options. I use them quite a bit for the Toolbawks suite I am building.
For your project, strip environment.rb down as much as you can by extracting and spliting the options out into individual.rb files inside initializers. This will clean it up and keep it much more organized for future releases of Toolbawks in particular.
Not sure if this wasn't in 1.2.6 or not, but I seen an update to the root route change in the new default Rails project. Change your empty route (root url) to be like this, but with your own controller/action:
create_table :collections do |t|
t.string :title
t.text :description
t.integer :count
t.integer :created_by
t.datetime :created_at
t.datetime :modified_at
end
As you can see the 2.0 syntax is much cleaner, but for all your old migrations this is sorta a waste of time to update as far as I'm concerned. So refactor when needed, and use the new syntax from now on.
The breakpoint server has changed, and the environment.rb config option is no longer needed. This really doesn't do much if it's in the config, but to get rid of the deprecation warning, I suggest removing it:
config.breakpoint_server = true
Pagination has been removed from Rails core, so you will need to upgrade that. I suggest using the will_paginate plugin. Checkout their site for upgrade instructions. Or you can use the classic_pagination if you don't need serious performance increases. The code is claimed to be dead for classic_pagination, so I suggest upgrading now to will_paginate, to avoid confusion later.
I had a problem with some of my logger code, so I added this line in one of my lib files to give me a global logger function I can use anywhere. This will later be extracted into a plugin for more comprehensive logging functionalities, but for now a simple addition of these three lines worked:
def logger
RAILS_DEFAULT_LOGGER
end
Engines.current.version no longer exists, so if you want that sort of functionality to see what version the engine is, add a new property to your plugin like so:
module DatetimeToolbawks
mattr_accessor :version
self.version = false
end
And add this to your init.rb script within your plugin.
That's it for now. Pretty sure I missed a few things, so when I update another app to Engines/Rails 2.0 I'll be sure to refresh this page with any additional upgrade steps.
All the Toolbawks plugins are now functioning for Rails 2.0, so it would be wise to get on board, reap the benefits of the