Thursday, January 3, 2008

Things to know while developing plugins with rails-engine

There are massive radical changes with rails-engine 1.2.0. Earlier a new engine could be created using ruby script/generate engine enginenameThis has been changed now. With no more distinction between an engine and a plugin one can create a new engine (or simply a plug-in from version 1.2.0 onwards) using
ruby script/generate plugin pluginname
Do not copy and edit the plugin's routes.rb from config/routes.rb. The reason being draw method clears the existing routes before adding the new ones (Ruby on Rails 1.2.3: routing.rb). The following in plugins/pluginname/routes.rb might not work properly.
ActionController::Routing::Routes.draw do |map|

     # No map.connect here
     resource :resourcename
end
Instead only copy the desired routes like
resource :resourcename
I had to struggle for hours to understand and resolve the problems due to this minor issue.

No comments: