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:innormalize_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:innew’
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:indecomposed_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:ineach’
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:ininstance_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:indraw’
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:inload’
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:inload’
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:ineach’
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:inreload!’
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:incall’
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:inupdater’
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:ininstance_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:inrun_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:inrun_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:insend’
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:inrequire’
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:ininitialize’
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

On 19 July 2012 17:19, Shandy N. [email protected] wrote:

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:

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 L. wrote in post #1069377:

On 19 July 2012 17:19, Shandy N. [email protected] wrote:

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

That’s what I thought, but I keep getting “No route matches [GET]
“/agency/login”” error, so I’m wonder if I have something else setup
incorrectly. Thanks for the response,

-S

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.

2012/7/20 Colin L. [email protected]

On 20 July 2012 16:24, Shandy N. [email protected] wrote:

That’s what I thought, but I keep getting “No route matches [GET]
“/agency/login”” error, so I’m wonder if I have something else setup
incorrectly. Thanks for the response,

What url are you using that gives that?

Colin

Colin L. wrote in post #1069541:

On 20 July 2012 17:44, Gintautas Šimkus [email protected] wrote:

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

On 20 July 2012 21:38, Shandy N. [email protected] wrote:

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,

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 L. wrote in post #1069548:

On 20 July 2012 21:38, Shandy N. [email protected] wrote:

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”

-S

On 20 July 2012 17:44, Gintautas Šimkus [email protected] wrote:

Hey Shandy, use

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

Is that better then root :to=>… ?

Colin

On 20 July 2012 22:02, Shandy N. [email protected] wrote:

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=>

Colin

On 20 July 2012 22:12, Colin L. [email protected] wrote:

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