Forum: Ruby on Rails Rails 1.2 / Theme support plugin issue: Fix

Posted by Open Web20 (openweb20)
on 2007-03-06 01:12
This is to answer one of my old issues, that I was having using Theme
support plugin using with Rails 1.2.

When you get an latest edge Rails update and run your application which
has Theme support plugin you will get following error

/script/../config/../vendor/plugins/theme_support/lib/patches/routeset_ex.rb:26:in
`create_theme_routes': undefined method `named_route' for
#<ActionController::Routing::RouteSet:0x1313b78> (NoMethodError)
 from
./script/../config/../vendor/plugins/theme_support/lib/patches/routeset_ex.rb:13:in
`draw'
 from ./script/../config/../config/routes.rb:1


Fix that I found for this is

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

   def draw
        clear!
        create_theme_routes
        yield Mapper.new(self)
        named_routes.install
   end

# 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',
:action=>'stylesheets'
    add_named_route 'theme_javascript',
"/themes/:theme/javascript/:filename", :controller=>'theme',
:action=>'javascript'

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

This should do the trick. I have tested this on Rails 1.2.1 and 1.2.2
Posted by Wes Rogers (wesr)
on 2007-03-16 19:38
Thank you!
Posted by captain (Guest)
on 2007-04-03 10:25
Rajesh Shetty wrote:
> This is to answer one of my old issues, that I was having using Theme
> support plugin using with Rails 1.2.
> 
> When you get an latest edge Rails update and run your application which
> has Theme support plugin you will get following error
> 
> /script/../config/../vendor/plugins/theme_support/lib/patches/routeset_ex.rb:26:in
> `create_theme_routes': undefined method `named_route' for
> #<ActionController::Routing::RouteSet:0x1313b78> (NoMethodError)
>  from
> ./script/../config/../vendor/plugins/theme_support/lib/patches/routeset_ex.rb:13:in
> `draw'
>  from ./script/../config/../config/routes.rb:1
> 
> 
> Fix that I found for this is
> 
> # Go to vendor/plugins/theme_support/lib/patches/routeset_ex.rb
> # Replace "draw" method with following
> 
>    def draw

Thanks for Rajesh's answer. But how about rails1.2.3, i got such error:
=> Booting WEBrick...
d:/ruby/lib/ruby/site_ruby/1.8/rubygems.rb:246:in `activate': can't 
activate rai
ls (= 1.1.6), already activated rails-1.2.3] (Gem::Exception)
        from d:/ruby/lib/ruby/site_ruby/1.8/rubygems.rb:264:in 
`activate'
        from d:/ruby/lib/ruby/site_ruby/1.8/rubygems.rb:263:in `each'
        from d:/ruby/lib/ruby/site_ruby/1.8/rubygems.rb:263:in 
`activate'
        from 
d:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `re
quire'
        from 
d:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/active_suppo
rt/dependencies.rb:495:in `require'
        from 
d:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/active_suppo
rt/dependencies.rb:342:in `new_constants_in'
        from 
d:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/active_suppo
rt/dependencies.rb:495:in `require'
        from 
d:/ruby/lib/ruby/gems/1.8/gems/rails-1.2.3/lib/commands/servers/web
rick.rb:52
        from 
d:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `ge
m_original_require'
        from 
d:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `re
quire'
        from 
d:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/active_suppo
rt/dependencies.rb:495:in `require'
        from 
d:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/active_suppo
rt/dependencies.rb:342:in `new_constants_in'
        from 
d:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.2/lib/active_suppo
rt/dependencies.rb:495:in `require'
        from 
d:/ruby/lib/ruby/gems/1.8/gems/rails-1.2.3/lib/commands/server.rb:3
9
        from 
d:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `ge
m_original_require'
        from 
d:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `re
quire'
        from script/server:3

Can you do me a favour?
Regards.
captain
>         clear!
>         create_theme_routes
>         yield Mapper.new(self)
>         named_routes.install
>    end
> 
> # 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',
> :action=>'stylesheets'
>     add_named_route 'theme_javascript',
> "/themes/:theme/javascript/:filename", :controller=>'theme',
> :action=>'javascript'
> 
>     add_route "/themes/*whatever", :controller=>'theme',
> :action=>'error'
>   end
> 
> This should do the trick. I have tested this on Rails 1.2.1 and 1.2.2
Posted by Open Web20 (openweb20)
on 2007-04-25 07:51
Sorry for real delayed answer. I have not played with Rails 1.2.3
release yet. If I have any update for that I will post it here
Posted by Andy -- (summea)
on 2007-07-14 01:33
Rajesh,

Thank you for posting this fix!
I've been hitting problem after problem while learning how to use Ruby 
on Rails (and themes,) and this fixed my problem!

I'm using Rails 1.2.3  and the fix you described WORKS for Rails 1.2.3 
on Mac OS X (at least).
Thanks again!

Andy


Rajesh Shetty wrote:
> Sorry for real delayed answer. I have not played with Rails 1.2.3
> release yet. If I have any update for that I will post it here
Posted by summea (Guest)
on 2007-07-19 06:59
(Received via mailing list)
But I have another question...

How do you get the layout part working?

For example, if a theme has a particular layout that I want to use...
what do I need to fix in order to be able to use a theme's layout?


Andy
Please log in before posting. Registration is free and takes only a minute.
Existing account (Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
No account? Register here.