Ruby on Rails Wednesday, November 28, 2012

On Wed, Nov 28, 2012 at 2:42 AM, Sumit Srivastava
<sumit.theinvincible@gmail.com> wrote:
> Hi,
>
> I have a controller named users and index action in it. By default I have
> the path
>
> get '/users' => 'users#index', :as => 'users'
>
> Now I want to create one more path with a different parameter being passed
>
> get '/users/:city' => 'users#index', :as => 'list_users'
>
> But this gives as error, No route matches {:controller=>"users"}.
>
> I ran rake routes and found the path I defined to be present over there but
> it doesn't works.
>
> What shall be done to make this work.

I've no experience with routes exactly like that (considering to me it
seems illogical) but maybe Rails see the same broken logic, in that
you are trying to define two routes to same action when one route
/should/ be a /one action/ have you tried creating a new action in
your controller and seeing if the error still happens? Example: "get
"/users/:city" => "users#by_city", :as => "by_city" but since I've not
seen the entire error and just what rails reports at the top are you
sure UsersController has index? Are you sure it's not User instead of
Users (I don't quite remember of Rails will do the plural game on
routes like it does with tables via ActiveRecord.)

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

No comments:

Post a Comment