Rails3 routes

Hi all,

I'm trying to convert what I think are some pretty straight forward Rail2 routes to Rails3 routes with no success.

I have map.connect '', :controller => "agency" which I have tried converting to match '', :to => 'agency' which then throws an error saying:

/home/shandy/.rvm/gems/ruby-1.8.7-p370/gems/actionpack-3.2.2/lib/action_dispatch/routing/mapper.rb:183:in `default_controller_and_action': missing :action (ArgumentError)         from /home/shandy/.rvm/gems/ruby-1.8.7-p370/gems/actionpack-3.2.2/lib/action_dispatch/routing/mapper.rb:76:in `normalize_options!'         from /home/shandy/.rvm/gems/ruby-1.8.7-p370/gems/actionpack-3.2.2/lib/action_dispatch/routing/mapper.rb:59:in `initialize'         from /home/shandy/.rvm/gems/ruby-1.8.7-p370/gems/actionpack-3.2.2/lib/action_dispatch/routing/mapper.rb:1302:in `new'         from /home/shandy/.rvm/gems/ruby-1.8.7-p370/gems/actionpack-3.2.2/lib/action_dispatch/routing/mapper.rb:1302:in `add_route'         from /home/shandy/.rvm/gems/ruby-1.8.7-p370/gems/actionpack-3.2.2/lib/action_dispatch/routing/mapper.rb:1282:in `decomposed_match'         from /home/shandy/.rvm/gems/ruby-1.8.7-p370/gems/actionpack-3.2.2/lib/action_dispatch/routing/mapper.rb:1268:in `match'         from /home/shandy/.rvm/gems/ruby-1.8.7-p370/gems/actionpack-3.2.2/lib/action_dispatch/routing/mapper.rb:1268:in `each'         from /home/shandy/.rvm/gems/ruby-1.8.7-p370/gems/actionpack-3.2.2/lib/action_dispatch/routing/mapper.rb:1268:in `match'         from /home/shandy/npower/config/routes.rb:74         from /home/shandy/.rvm/gems/ruby-1.8.7-p370/gems/actionpack-3.2.2/lib/action_dispatch/routing/route_set.rb:276:in `instance_exec'         from /home/shandy/.rvm/gems/ruby-1.8.7-p370/gems/actionpack-3.2.2/lib/action_dispatch/routing/route_set.rb:276:in `eval_block'         from /home/shandy/.rvm/gems/ruby-1.8.7-p370/gems/actionpack-3.2.2/lib/action_dispatch/routing/route_set.rb:254:in `draw'         from /home/shandy/npower/config/routes.rb:1         from /home/shandy/.rvm/gems/ruby-1.8.7-p370/gems/activesupport-3.2.2/lib/active_support/dependencies.rb:245:in `load'         from /home/shandy/.rvm/gems/ruby-1.8.7-p370/gems/activesupport-3.2.2/lib/active_support/dependencies.rb:245:in `load'         from /home/shandy/.rvm/gems/ruby-1.8.7-p370/gems/activesupport-3.2.2/lib/active_support/dependencies.rb:236:in `load_dependency'         from /home/shandy/.rvm/gems/ruby-1.8.7-p370/gems/activesupport-3.2.2/lib/active_support/dependencies.rb:245:in `load'         from /home/shandy/.rvm/gems/ruby-1.8.7-p370/gems/railties-3.2.2/lib/rails/application/routes_reloader.rb:40:in `load_paths'         from /home/shandy/.rvm/gems/ruby-1.8.7-p370/gems/railties-3.2.2/lib/rails/application/routes_reloader.rb:40:in `each'         from /home/shandy/.rvm/gems/ruby-1.8.7-p370/gems/railties-3.2.2/lib/rails/application/routes_reloader.rb:40:in `load_paths'         from /home/shandy/.rvm/gems/ruby-1.8.7-p370/gems/railties-3.2.2/lib/rails/application/routes_reloader.rb:16:in `reload!'         from /home/shandy/.rvm/gems/ruby-1.8.7-p370/gems/railties-3.2.2/lib/rails/application/routes_reloader.rb:26:in `updater'         from /home/shandy/.rvm/gems/ruby-1.8.7-p370/gems/activesupport-3.2.2/lib/active_support/file_update_checker.rb:78:in `call'         from /home/shandy/.rvm/gems/ruby-1.8.7-p370/gems/activesupport-3.2.2/lib/active_support/file_update_checker.rb:78:in `execute'         from /home/shandy/.rvm/gems/ruby-1.8.7-p370/gems/railties-3.2.2/lib/rails/application/routes_reloader.rb:27:in `updater'         from /home/shandy/.rvm/gems/ruby-1.8.7-p370/gems/railties-3.2.2/lib/rails/application/routes_reloader.rb:7:in `execute_if_updated'         from /home/shandy/.rvm/gems/ruby-1.8.7-p370/gems/railties-3.2.2/lib/rails/application/finisher.rb:66         from /home/shandy/.rvm/gems/ruby-1.8.7-p370/gems/railties-3.2.2/lib/rails/initializable.rb:30:in `instance_exec'         from /home/shandy/.rvm/gems/ruby-1.8.7-p370/gems/railties-3.2.2/lib/rails/initializable.rb:30:in `run'         from /home/shandy/.rvm/gems/ruby-1.8.7-p370/gems/railties-3.2.2/lib/rails/initializable.rb:55:in `run_initializers'         from /home/shandy/.rvm/gems/ruby-1.8.7-p370/gems/railties-3.2.2/lib/rails/initializable.rb:54:in `each'         from /home/shandy/.rvm/gems/ruby-1.8.7-p370/gems/railties-3.2.2/lib/rails/initializable.rb:54:in `run_initializers'         from /home/shandy/.rvm/gems/ruby-1.8.7-p370/gems/railties-3.2.2/lib/rails/application.rb:136:in `initialize!'         from /home/shandy/.rvm/gems/ruby-1.8.7-p370/gems/railties-3.2.2/lib/rails/railtie/configurable.rb:30:in `send'         from /home/shandy/.rvm/gems/ruby-1.8.7-p370/gems/railties-3.2.2/lib/rails/railtie/configurable.rb:30:in `method_missing'         from /home/shandy/npower/config/environment.rb:5         from /home/shandy/npower/config.ru:4:in `require'         from /home/shandy/npower/config.ru:4         from /home/shandy/.rvm/gems/ruby-1.8.7-p370/gems/rack-1.4.1/lib/rack/builder.rb:51:in `instance_eval'         from /home/shandy/.rvm/gems/ruby-1.8.7-p370/gems/rack-1.4.1/lib/rack/builder.rb:51:in `initialize'         from /home/shandy/npower/config.ru:1:in `new'         from /home/shandy/npower/config.ru:1

I have also tried

Npower::Application.routes.draw do     match 'login', :to => 'agency' end

But then I get an error that says "No route matches [GET] "/agency"." If anybody has any ideas or could point me to a site that explains the differences/conversions of Rails2 routes to Rails3 routes, that would much appreciated. Thanks,

-S

Is that not just root :to => "agency#index" assuming the action you want is index. Unless I have forgotten how rails 2 routing worked.

Colin

Colin Law wrote in post #1069377:

What url are you using that gives that?

Colin

Hey Shandy, use

match ‘’, :to => ‘agency#index’

or replace index with another agency controller action explicitly.

In order to solve the second problem we’d need your routes.rb file (please use pastie.org or simple code formatting to make it easy to read.

Hey Shandy, use

match '', :to => 'agency#index'

Is that better then root :to=>... ?

Colin

Colin Law wrote in post #1069541:

Hey Shandy, use

match '', :to => 'agency#index'

Is that better then root :to=>... ?

Colin

When I do that I get this error:

syntax error, unexpected ':', expecting kEND (SyntaxError)   match '' :to => 'agency#index'             ^

I'm not sure if I have some issue with my rails setup, but it seems like everything I try it either doesn't work as expected, or errors when I stat the server. I'm running rails 3.2.2. Thanks for the suggestion,

-S

So what happens with root :to? Show us the exact line you have in routes.rb, what url you are asking for and what happens.

Colin

Colin Law wrote in post #1069548:

You still have not told us what url you are asking for when that happens, and exactly what you have specified for root :to=>

Colin

Colin Law wrote in post #1069548:

So what happens with root :to? Show us the exact line you have in routes.rb, what url you are asking for and what happens.

Colin

That works fine, in that the server starts. I'm still unable to bring up a specific page. I get: No route matches [GET] "/agency/login"

You still have not told us what url you are asking for when that happens, and exactly what you have specified for root :to=>

It is rather depressing how often this happens. A question is asked but the OP never responds. Presumably the OP realised his mistake in the process of answering the question but does not have the good manners to reply. :frowning:

Colin