Forum: Ruby on Rails named_route error with edge 1.2 & theme_support plugin

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
01615eabbbde4d504be0751f4ffdf26f?d=identicon&s=25 mattman (Guest)
on 2006-12-26 03:17
(Received via mailing list)
Hi everyone!

Hope all had a good Christmas

I've just frozen edge rails 1.2 into my vendor/rails dir, and tried
launching mongrel to test it, and got this:

C:\Documents and Settings\Matts\shop>mongrel_rails start
** Starting Mongrel listening at 0.0.0.0:3000
** Starting Rails with development environment ...
C:/Documents and
Settings/Matts/shop/config/../vendor/plugins/theme_support/lib/patches/routeset_ex.rb:27:in
`create_theme_routes': undefined method `named_route' for
#<ActionController::Routing::RouteSet:0x3374530> (NoMethodError) from
C:/Documents and
Settings/Matts/shop/config/../vendor/plugins/theme_support/lib/patches/routeset_ex.rb:13:in
`draw' from C:/Documents and
Settings/Matts/shop/config/../config/routes.rb:1
        from C:/Documents and
Settings/Matts/shop/config/../vendor/rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:487:in
`load' from C:/Documents and
Settings/Matts/shop/config/../vendor/rails/activer
ecord/lib/../../activesupport/lib/active_support/dependencies.rb:341:in
`new_con
stants_in' from C:/Documents and
Settings/Matts/shop/config/../vendor/rails/activerecord/lib/../../activesupport/lib/active_support/dependencies.rb:487:in
`load' from C:/Documents and
Settings/Matts/shop/config/../vendor/rails/actionpack/lib/action_controller/routing.rb:1151:in
`load_routes!' from C:/Documents and
Settings/Matts/shop/config/../vendor/rails/actionpack/lib/action_controller/routing.rb:1143:in
`reload' from C:/Documents and
Settings/Matts/shop/config/../vendor/rails/railties/lib/initializer.rb:287:in
`initialize_routing'  ... 9 levels... from
c:/ruby/lib/ruby/gems/1.8/gems/mongrel-0.3.13.3-mswin32/bin/mongrel_rails:83:in
`run'  from
c:/ruby/lib/ruby/gems/1.8/gems/mongrel-0.3.13.3-mswin32/lib/mongrel/command.rb:199:in
`run' from
c:/ruby/lib/ruby/gems/1.8/gems/mongrel-0.3.13.3-mswin32/bin/mongrel_rails:235
from c:/ruby/bin/mongrel_rails:18

My understanding of that is that it can't find the named_route function
in the actionpack/lib/actioncontroller/routing.rb file. The function is
def. in that file :S

This is how it's being called in the plugin

class ActionController::Routing::RouteSet

  alias_method :__draw, :draw

  # Overrides the default <tt>RouteSet#draw</tt> to automatically
  # include the routes needed by the <tt>ThemeController</tt>
  def draw
    old_routes = @routes
    @routes = []

    begin
      create_theme_routes
      yield self
    rescue
      @routes = old_routes
      raise
    end

    write_generation
    write_recognition
  end

  # Creates the required routes for the <tt>ThemeController</tt>...
  def create_theme_routes
    # Added patch from D.J. Vogel that changes <tt>:filename</tt> to
<tt>*filename</tt>... allowing sub-folders
    named_route 'theme_images', "/themes/:theme/images/*filename",
:controller=>'theme', :action=>'images'
    named_route 'theme_stylesheets',
"/themes/:theme/stylesheets/*filename", :controller=>'theme',
:action=>'stylesheets'
    named_route 'theme_javascript',
"/themes/:theme/javascript/*filename", :controller=>'theme',
:action=>'javascript'

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

Sorry for the long post, but I wanted to include everything here so it
was easier to help :D
Fe351aa18bdb90281044828701d67d08?d=identicon&s=25 Cedric Jolivet (cedjo)
on 2007-01-20 13:13
My temp solution for that is to empty routeset_ex.rb, and copy all the
routes in the file config/routes.rb:

#theme_support
  map.connect "/themes/:theme/images/*filename", :controller=>'theme',
:action=>'images'
  map.connect "/themes/:theme/stylesheets/*filename",
:controller=>'theme', :action=>'stylesheets'
  map.connect "/themes/:theme/javascript/*filename",
:controller=>'theme', :action=>'javascript'

  map.connect "/themes/*whatever", :controller=>'theme',
:action=>'error'

and it works well for me!
This topic is locked and can not be replied to.