Saturday, February 10, 2007

Rails 1.2 impact on Ajuby release 0.4

We are running into quite a few issues with latest Rails version 1.2 starting with Theme generator complaining about "named_route" , following is the exception that we get

=> Booting WEBrick...
./script/../config/../vendor/plugins/theme_support/lib/patches/routeset_ex.rb:26:in `create_theme_routes': undefined method `named_route' for #<actioncontroller::routing::routeset:0xb7d34690> (NoMethodError)
from script/../config/../vendor/plugins/theme_support/lib/patches/routeset_ex.rb:13:in `draw'

Reason is Theme generator is using its own routes extension for its custom routes and as per Rails 1.2 release , Routes section).

So meanwhile we figure out how to fix this or Theme generator comes with fix for Rails 1.2, Following is the fix that you can do

# Lets freeze the Rails for Ajuby release by running following command

> rake rails:freeze:edge TAG=rel_1-1-6

This will take rails 1.1.6 and make rails available within Ajuby framework, (We will eventually go this route. Every release will be bundled with Rails , so one less thing to worry with)

# After above step successfully complete, start the WEBrick and see if you run into any error , if yes possibly you would not have Activerecord core frozen properly. Not sure whether its a bug in the rake process. If you see this error like undefined method "deprecate" or #<Class:......

Copy activerecord/lib directory from your installed Rails (wherever you have installed rails version 1.1.6 before above freeze process) to <ajubyhome>/vendor/rails/activerecord/lib directory


Anonymous said...

You can also use the fix mentioned by 'cedric' here:

This entails just moving and reformating the named routes in routeset_ex.rb into config/routes.rb.

Rajesh Shetty said...

I did this fix provided by "cedric" and this fix has been posted in quite a few places but it never worked for me. I guess even if it works, my idea is to avoid moving out any code from Theme extension files to Rails routes code, with that we are cluttering routes.rb with your custom plugin routes and that is not a smart solution but its a good hack.
In fact I have found the solution that will work with Rails 1.2.X without moving anything out of Theme support code. I have posted the fix in this link

I'm also posting the fix here

# Go to vendor/plugins/theme_support/lib/patches/routeset_ex.rb
# Replace "draw" method with following

def draw

# In create_theme_routes method
- replace named_route with add_named_route
- replace connect with add_route

So your create_theme_routes should look like this

def create_theme_routes
add_named_route 'theme_images', "/themes/:theme/images/:filename",
:controller=>'theme', :action=>'images'
add_named_route 'theme_stylesheets',
"/themes/:theme/stylesheets/:filename", :controller=>'theme',
add_named_route 'theme_javascript',
"/themes/:theme/javascript/:filename", :controller=>'theme',

add_route "/themes/*whatever", :controller=>'theme',