Named_route error with edge 1.2 & theme_support plugin


#1

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 methodnamed_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:inload’ 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:inload’ 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:inreload’ 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:inrun’ 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 RouteSet#draw to automatically

include the routes needed by the ThemeController

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 ThemeController…

def create_theme_routes
# Added patch from D.J. Vogel that changes :filename to
*filename… 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 :smiley:


#2

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!