I have a controller: class HomeController < ApplicationController def index end def about end def contact end def terms end def privacy end end My routes.rb has: resources :home do member do get ''about'' get ''contact'' get ''terms'' get ''privacy'' end end In my application.html.erb I have: <li><a href="<%= about_home_path %>">About</a></li> It seems to be expecting an id? I''m getting the error: No route matches {:action=>"about", :controller=>"home"} Rake routes shows: about_home GET /home/:id/about(.:format) home#about -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit https://groups.google.com/groups/opt_out.
Maybe it could be a inflection problem: "home".pluralize "homes" The convention is that a controller is the pluralized name of the model. On Wed, Sep 19, 2012 at 10:32 PM, S Ahmed <sahmed1020-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I have a controller: > > class HomeController < ApplicationController > def index > > end > > def about > end > > def contact > end > > def terms > end > > def privacy > end > end > > My routes.rb has: > > resources :home do > member do > get ''about'' > get ''contact'' > get ''terms'' > get ''privacy'' > end > end > > > In my application.html.erb I have: > > <li><a href="<%= about_home_path %>">About</a></li> > > It seems to be expecting an id? > > I''m getting the error: > > > No route matches {:action=>"about", :controller=>"home"} > > > Rake routes shows: > > about_home GET /home/:id/about(.:format) home#about > > -- > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > For more options, visit https://groups.google.com/groups/opt_out. > > >-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit https://groups.google.com/groups/opt_out.
Use "collection" instead "member" http://guides.rubyonrails.org/routing.html#adding-more-restful-actions 2012/9/19 S Ahmed <sahmed1020-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>> I have a controller: > > class HomeController < ApplicationController > def index > > end > > def about > end > > def contact > end > > def terms > end > > def privacy > end > end > > My routes.rb has: > > resources :home do > member do > get ''about'' > get ''contact'' > get ''terms'' > get ''privacy'' > end > end > > > In my application.html.erb I have: > > <li><a href="<%= about_home_path %>">About</a></li> > > It seems to be expecting an id? > > I''m getting the error: > > > No route matches {:action=>"about", :controller=>"home"} > > > Rake routes shows: > > about_home GET /home/:id/about(.:format) home#about > > -- > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > For more options, visit https://groups.google.com/groups/opt_out. > > >-- Fernando Almeida www.fernandoalmeida.net -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit https://groups.google.com/groups/opt_out.
Thanks, that worked. Although it doesn''t make sense, it isnt'' a colleciton so I guessed to use member. BTW, how could I match this: /home/some-name-here Where ''some-name-here'' is the parameter (id), and I want to call home#show On Wed, Sep 19, 2012 at 9:56 PM, Fernando Almeida < fernando-7WGqr3rU1tV1NwFxuVVnt9HuzzzSOjJt@public.gmane.org> wrote:> Use "collection" instead "member" > http://guides.rubyonrails.org/routing.html#adding-more-restful-actions > > 2012/9/19 S Ahmed <sahmed1020-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > >> I have a controller: >> >> class HomeController < ApplicationController >> def index >> >> end >> >> def about >> end >> >> def contact >> end >> >> def terms >> end >> >> def privacy >> end >> end >> >> My routes.rb has: >> >> resources :home do >> member do >> get ''about'' >> get ''contact'' >> get ''terms'' >> get ''privacy'' >> end >> end >> >> >> In my application.html.erb I have: >> >> <li><a href="<%= about_home_path %>">About</a></li> >> >> It seems to be expecting an id? >> >> I''m getting the error: >> >> >> No route matches {:action=>"about", :controller=>"home"} >> >> >> Rake routes shows: >> >> about_home GET /home/:id/about(.:format) home#about >> >> -- >> 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >> To unsubscribe from this group, send email to >> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >> For more options, visit https://groups.google.com/groups/opt_out. >> >> >> > > > > -- > Fernando Almeida > www.fernandoalmeida.net > > > -- > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > For more options, visit https://groups.google.com/groups/opt_out. > > >-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit https://groups.google.com/groups/opt_out.
You can use match ''home/:page'' => ''home#page'' <<<< before resources :home <<<< after # home_controller def page # use params[:page] end Rails routes are matched in the order they are specified, so if you have a resources :photos above a get ''photos/poll'' the show action’s route for the resourcesline will be matched before the get line. To fix this, move the get line *above* the resources line so that it is matched first. http://guides.rubyonrails.org/routing.html#crud-verbs-and-actions 2012/9/19 S Ahmed <sahmed1020-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>> Thanks, that worked. Although it doesn''t make sense, it isnt'' a > colleciton so I guessed to use member. > > BTW, how could I match this: > > /home/some-name-here > > Where ''some-name-here'' is the parameter (id), and I want to call home#show > > > On Wed, Sep 19, 2012 at 9:56 PM, Fernando Almeida < > fernando-7WGqr3rU1tV1NwFxuVVnt9HuzzzSOjJt@public.gmane.org> wrote: > >> Use "collection" instead "member" >> http://guides.rubyonrails.org/routing.html#adding-more-restful-actions >> >> 2012/9/19 S Ahmed <sahmed1020-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> >> >>> I have a controller: >>> >>> class HomeController < ApplicationController >>> def index >>> >>> end >>> >>> def about >>> end >>> >>> def contact >>> end >>> >>> def terms >>> end >>> >>> def privacy >>> end >>> end >>> >>> My routes.rb has: >>> >>> resources :home do >>> member do >>> get ''about'' >>> get ''contact'' >>> get ''terms'' >>> get ''privacy'' >>> end >>> end >>> >>> >>> In my application.html.erb I have: >>> >>> <li><a href="<%= about_home_path %>">About</a></li> >>> >>> It seems to be expecting an id? >>> >>> I''m getting the error: >>> >>> >>> No route matches {:action=>"about", :controller=>"home"} >>> >>> >>> Rake routes shows: >>> >>> about_home GET /home/:id/about(.:format) home#about >>> >>> -- >>> 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>> To unsubscribe from this group, send email to >>> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>> For more options, visit https://groups.google.com/groups/opt_out. >>> >>> >>> >> >> >> >> -- >> Fernando Almeida >> www.fernandoalmeida.net >> >> >> -- >> 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >> To unsubscribe from this group, send email to >> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >> For more options, visit https://groups.google.com/groups/opt_out. >> >> >> > > -- > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > For more options, visit https://groups.google.com/groups/opt_out. > > >-- Fernando Almeida www.fernandoalmeida.net -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
On Thu, Sep 20, 2012 at 12:13 PM, Fernando Almeida < fernando-7WGqr3rU1tV1NwFxuVVnt9HuzzzSOjJt@public.gmane.org> wrote:> You can use > > match ''home/:page'' => ''home#page'' <<<< before > resources :home <<<< after >this isn''t advisable. home/:page will match home/1> > # home_controller > def page > # use params[:page] > end > > Rails routes are matched in the order they are specified, so if you have a resources > :photos above a get ''photos/poll'' the show action’s route for the > resources line will be matched before the get line. To fix this, move the > get line *above* the resources line so that it is matched first. > http://guides.rubyonrails.org/routing.html#crud-verbs-and-actions > > > > 2012/9/19 S Ahmed <sahmed1020-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > >> Thanks, that worked. Although it doesn''t make sense, it isnt'' a >> colleciton so I guessed to use member. >> >> BTW, how could I match this: >> >> /home/some-name-here >> >> Where ''some-name-here'' is the parameter (id), and I want to call home#show >> >> >> On Wed, Sep 19, 2012 at 9:56 PM, Fernando Almeida < >> fernando-7WGqr3rU1tV1NwFxuVVnt9HuzzzSOjJt@public.gmane.org> wrote: >> >>> Use "collection" instead "member" >>> http://guides.rubyonrails.org/routing.html#adding-more-restful-actions >>> >>> 2012/9/19 S Ahmed <sahmed1020-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> >>> >>>> I have a controller: >>>> >>>> class HomeController < ApplicationController >>>> def index >>>> >>>> end >>>> >>>> def about >>>> end >>>> >>>> def contact >>>> end >>>> >>>> def terms >>>> end >>>> >>>> def privacy >>>> end >>>> end >>>> >>>> My routes.rb has: >>>> >>>> resources :home do >>>> member do >>>> get ''about'' >>>> get ''contact'' >>>> get ''terms'' >>>> get ''privacy'' >>>> end >>>> end >>>> >>>> >>>> In my application.html.erb I have: >>>> >>>> <li><a href="<%= about_home_path %>">About</a></li> >>>> >>>> It seems to be expecting an id? >>>> >>>> I''m getting the error: >>>> >>>> No route matches {:action=>"about", :controller=>"home"} >>>> >>>> >>>> Rake routes shows: >>>> >>>> about_home GET /home/:id/about(.:format) home#about >>>> >>>> -- >>>> 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org. >>>> To unsubscribe from this group, send email to >>>> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>> For more options, visit https://groups.google.com/groups/opt_out. >>>> >>>> >>>> >>> >>> >>> >>> -- >>> Fernando Almeida >>> www.fernandoalmeida.net >>> >>> >>> -- >>> 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>> To unsubscribe from this group, send email to >>> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>> For more options, visit https://groups.google.com/groups/opt_out. >>> >>> >>> >> >> -- >> 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >> To unsubscribe from this group, send email to >> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >> For more options, visit https://groups.google.com/groups/opt_out. >> >> >> > > > > -- > Fernando Almeida > www.fernandoalmeida.net > > -- > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > For more options, visit https://groups.google.com/groups/opt_out. > > >-- ------------------------------------------------------------- visit my blog at http://jimlabs.heroku.com -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Not if defined before the resource. 2012/9/19 Jim Ruther Nill <jvnill-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>> > > On Thu, Sep 20, 2012 at 12:13 PM, Fernando Almeida < > fernando-7WGqr3rU1tV1NwFxuVVnt9HuzzzSOjJt@public.gmane.org> wrote: > >> You can use >> >> match ''home/:page'' => ''home#page'' <<<< before >> resources :home <<<< after >> > > this isn''t advisable. home/:page will match home/1 > > >> >> # home_controller >> def page >> # use params[:page] >> end >> >> Rails routes are matched in the order they are specified, so if you have >> a resources :photos above a get ''photos/poll'' the show action’s route >> for the resources line will be matched before the get line. To fix this, >> move the get line *above* the resources line so that it is matched first. >> http://guides.rubyonrails.org/routing.html#crud-verbs-and-actions >> >> >> >> 2012/9/19 S Ahmed <sahmed1020-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> >> >>> Thanks, that worked. Although it doesn''t make sense, it isnt'' a >>> colleciton so I guessed to use member. >>> >>> BTW, how could I match this: >>> >>> /home/some-name-here >>> >>> Where ''some-name-here'' is the parameter (id), and I want to call >>> home#show >>> >>> >>> On Wed, Sep 19, 2012 at 9:56 PM, Fernando Almeida < >>> fernando-7WGqr3rU1tV1NwFxuVVnt9HuzzzSOjJt@public.gmane.org> wrote: >>> >>>> Use "collection" instead "member" >>>> http://guides.rubyonrails.org/routing.html#adding-more-restful-actions >>>> >>>> 2012/9/19 S Ahmed <sahmed1020-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> >>>> >>>>> I have a controller: >>>>> >>>>> class HomeController < ApplicationController >>>>> def index >>>>> >>>>> end >>>>> >>>>> def about >>>>> end >>>>> >>>>> def contact >>>>> end >>>>> >>>>> def terms >>>>> end >>>>> >>>>> def privacy >>>>> end >>>>> end >>>>> >>>>> My routes.rb has: >>>>> >>>>> resources :home do >>>>> member do >>>>> get ''about'' >>>>> get ''contact'' >>>>> get ''terms'' >>>>> get ''privacy'' >>>>> end >>>>> end >>>>> >>>>> >>>>> In my application.html.erb I have: >>>>> >>>>> <li><a href="<%= about_home_path %>">About</a></li> >>>>> >>>>> It seems to be expecting an id? >>>>> >>>>> I''m getting the error: >>>>> >>>>> >>>>> No route matches {:action=>"about", :controller=>"home"} >>>>> >>>>> >>>>> Rake routes shows: >>>>> >>>>> about_home GET /home/:id/about(.:format) home#about >>>>> >>>>> -- >>>>> 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-/JYPxA39Uh4Ykp1iOSErHA@public.gmane.orgm >>>>> . >>>>> To unsubscribe from this group, send email to >>>>> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>>> For more options, visit https://groups.google.com/groups/opt_out. >>>>> >>>>> >>>>> >>>> >>>> >>>> >>>> -- >>>> Fernando Almeida >>>> www.fernandoalmeida.net >>>> >>>> >>>> -- >>>> 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org. >>>> To unsubscribe from this group, send email to >>>> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>> For more options, visit https://groups.google.com/groups/opt_out. >>>> >>>> >>>> >>> >>> -- >>> 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>> To unsubscribe from this group, send email to >>> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>> For more options, visit https://groups.google.com/groups/opt_out. >>> >>> >>> >> >> >> >> -- >> Fernando Almeida >> www.fernandoalmeida.net >> >> -- >> 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >> To unsubscribe from this group, send email to >> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >> For more options, visit https://groups.google.com/groups/opt_out. >> >> >> > > > > -- > ------------------------------------------------------------- > visit my blog at http://jimlabs.heroku.com > > -- > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > For more options, visit https://groups.google.com/groups/opt_out. > > >-- Fernando Almeida www.fernandoalmeida.net -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
On Thu, Sep 20, 2012 at 12:32 PM, Fernando Almeida < fernando-7WGqr3rU1tV1NwFxuVVnt9HuzzzSOjJt@public.gmane.org> wrote:> Not if defined before the resource.i''m not saying that it won''t work. i''m saying that it''s not good practice. i would''ve agreed with your method if you added constraints to values of the :page parameter.> > > 2012/9/19 Jim Ruther Nill <jvnill-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > >> >> >> On Thu, Sep 20, 2012 at 12:13 PM, Fernando Almeida < >> fernando-7WGqr3rU1tV1NwFxuVVnt9HuzzzSOjJt@public.gmane.org> wrote: >> >>> You can use >>> >>> match ''home/:page'' => ''home#page'' <<<< before >>> resources :home <<<< after >>> >> >> this isn''t advisable. home/:page will match home/1 >> >> >>> >>> # home_controller >>> def page >>> # use params[:page] >>> end >>> >>> Rails routes are matched in the order they are specified, so if you have >>> a resources :photos above a get ''photos/poll'' the show action’s route >>> for the resources line will be matched before the get line. To fix >>> this, move the get line *above* the resources line so that it is >>> matched first. >>> http://guides.rubyonrails.org/routing.html#crud-verbs-and-actions >>> >>> >>> >>> 2012/9/19 S Ahmed <sahmed1020-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> >>> >>>> Thanks, that worked. Although it doesn''t make sense, it isnt'' a >>>> colleciton so I guessed to use member. >>>> >>>> BTW, how could I match this: >>>> >>>> /home/some-name-here >>>> >>>> Where ''some-name-here'' is the parameter (id), and I want to call >>>> home#show >>>> >>>> >>>> On Wed, Sep 19, 2012 at 9:56 PM, Fernando Almeida < >>>> fernando-7WGqr3rU1tV1NwFxuVVnt9HuzzzSOjJt@public.gmane.org> wrote: >>>> >>>>> Use "collection" instead "member" >>>>> http://guides.rubyonrails.org/routing.html#adding-more-restful-actions >>>>> >>>>> 2012/9/19 S Ahmed <sahmed1020-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> >>>>> >>>>>> I have a controller: >>>>>> >>>>>> class HomeController < ApplicationController >>>>>> def index >>>>>> >>>>>> end >>>>>> >>>>>> def about >>>>>> end >>>>>> >>>>>> def contact >>>>>> end >>>>>> >>>>>> def terms >>>>>> end >>>>>> >>>>>> def privacy >>>>>> end >>>>>> end >>>>>> >>>>>> My routes.rb has: >>>>>> >>>>>> resources :home do >>>>>> member do >>>>>> get ''about'' >>>>>> get ''contact'' >>>>>> get ''terms'' >>>>>> get ''privacy'' >>>>>> end >>>>>> end >>>>>> >>>>>> >>>>>> In my application.html.erb I have: >>>>>> >>>>>> <li><a href="<%= about_home_path %>">About</a></li> >>>>>> >>>>>> It seems to be expecting an id? >>>>>> >>>>>> I''m getting the error: >>>>>> >>>>>> No route matches {:action=>"about", :controller=>"home"} >>>>>> >>>>>> >>>>>> Rake routes shows: >>>>>> >>>>>> about_home GET /home/:id/about(.:format) home#about >>>>>> >>>>>> -- >>>>>> 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>>>> To unsubscribe from this group, send email to >>>>>> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>>>> For more options, visit https://groups.google.com/groups/opt_out. >>>>>> >>>>>> >>>>>> >>>>> >>>>> >>>>> >>>>> -- >>>>> Fernando Almeida >>>>> www.fernandoalmeida.net >>>>> >>>>> >>>>> -- >>>>> 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-/JYPxA39Uh4Ykp1iOSErHA@public.gmane.orgm >>>>> . >>>>> To unsubscribe from this group, send email to >>>>> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>>> For more options, visit https://groups.google.com/groups/opt_out. >>>>> >>>>> >>>>> >>>> >>>> -- >>>> 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org. >>>> To unsubscribe from this group, send email to >>>> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>> For more options, visit https://groups.google.com/groups/opt_out. >>>> >>>> >>>> >>> >>> >>> >>> -- >>> Fernando Almeida >>> www.fernandoalmeida.net >>> >>> -- >>> 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>> To unsubscribe from this group, send email to >>> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>> For more options, visit https://groups.google.com/groups/opt_out. >>> >>> >>> >> >> >> >> -- >> ------------------------------------------------------------- >> visit my blog at http://jimlabs.heroku.com >> >> -- >> 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >> To unsubscribe from this group, send email to >> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >> For more options, visit https://groups.google.com/groups/opt_out. >> >> >> > > > > -- > Fernando Almeida > www.fernandoalmeida.net > > -- > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > For more options, visit https://groups.google.com/groups/opt_out. > > >-- ------------------------------------------------------------- visit my blog at http://jimlabs.heroku.com -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
hummm... really, I agree with you. 2012/9/19 Jim Ruther Nill <jvnill-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>> > > On Thu, Sep 20, 2012 at 12:32 PM, Fernando Almeida < > fernando-7WGqr3rU1tV1NwFxuVVnt9HuzzzSOjJt@public.gmane.org> wrote: > >> Not if defined before the resource. > > > i''m not saying that it won''t work. i''m saying that it''s not good practice. > i would''ve agreed > with your method if you added constraints to values of the :page parameter. > > >> >> >> 2012/9/19 Jim Ruther Nill <jvnill-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> >> >>> >>> >>> On Thu, Sep 20, 2012 at 12:13 PM, Fernando Almeida < >>> fernando-7WGqr3rU1tV1NwFxuVVnt9HuzzzSOjJt@public.gmane.org> wrote: >>> >>>> You can use >>>> >>>> match ''home/:page'' => ''home#page'' <<<< before >>>> resources :home <<<< after >>>> >>> >>> this isn''t advisable. home/:page will match home/1 >>> >>> >>>> >>>> # home_controller >>>> def page >>>> # use params[:page] >>>> end >>>> >>>> Rails routes are matched in the order they are specified, so if you >>>> have a resources :photos above a get ''photos/poll'' the show action’s >>>> route for the resources line will be matched before the get line. To >>>> fix this, move the get line *above* the resources line so that it is >>>> matched first. >>>> http://guides.rubyonrails.org/routing.html#crud-verbs-and-actions >>>> >>>> >>>> >>>> 2012/9/19 S Ahmed <sahmed1020-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> >>>> >>>>> Thanks, that worked. Although it doesn''t make sense, it isnt'' a >>>>> colleciton so I guessed to use member. >>>>> >>>>> BTW, how could I match this: >>>>> >>>>> /home/some-name-here >>>>> >>>>> Where ''some-name-here'' is the parameter (id), and I want to call >>>>> home#show >>>>> >>>>> >>>>> On Wed, Sep 19, 2012 at 9:56 PM, Fernando Almeida < >>>>> fernando-7WGqr3rU1tV1NwFxuVVnt9HuzzzSOjJt@public.gmane.org> wrote: >>>>> >>>>>> Use "collection" instead "member" >>>>>> http://guides.rubyonrails.org/routing.html#adding-more-restful-actions >>>>>> >>>>>> 2012/9/19 S Ahmed <sahmed1020-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> >>>>>> >>>>>>> I have a controller: >>>>>>> >>>>>>> class HomeController < ApplicationController >>>>>>> def index >>>>>>> >>>>>>> end >>>>>>> >>>>>>> def about >>>>>>> end >>>>>>> >>>>>>> def contact >>>>>>> end >>>>>>> >>>>>>> def terms >>>>>>> end >>>>>>> >>>>>>> def privacy >>>>>>> end >>>>>>> end >>>>>>> >>>>>>> My routes.rb has: >>>>>>> >>>>>>> resources :home do >>>>>>> member do >>>>>>> get ''about'' >>>>>>> get ''contact'' >>>>>>> get ''terms'' >>>>>>> get ''privacy'' >>>>>>> end >>>>>>> end >>>>>>> >>>>>>> >>>>>>> In my application.html.erb I have: >>>>>>> >>>>>>> <li><a href="<%= about_home_path %>">About</a></li> >>>>>>> >>>>>>> It seems to be expecting an id? >>>>>>> >>>>>>> I''m getting the error: >>>>>>> >>>>>>> >>>>>>> No route matches {:action=>"about", :controller=>"home"} >>>>>>> >>>>>>> >>>>>>> Rake routes shows: >>>>>>> >>>>>>> about_home GET /home/:id/about(.:format) home#about >>>>>>> >>>>>>> -- >>>>>>> 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>>>>> To unsubscribe from this group, send email to >>>>>>> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>>>>> For more options, visit https://groups.google.com/groups/opt_out. >>>>>>> >>>>>>> >>>>>>> >>>>>> >>>>>> >>>>>> >>>>>> -- >>>>>> Fernando Almeida >>>>>> www.fernandoalmeida.net >>>>>> >>>>>> >>>>>> -- >>>>>> 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>>>> To unsubscribe from this group, send email to >>>>>> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>>>> For more options, visit https://groups.google.com/groups/opt_out. >>>>>> >>>>>> >>>>>> >>>>> >>>>> -- >>>>> 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-/JYPxA39Uh4Ykp1iOSErHA@public.gmane.orgm >>>>> . >>>>> To unsubscribe from this group, send email to >>>>> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>>> For more options, visit https://groups.google.com/groups/opt_out. >>>>> >>>>> >>>>> >>>> >>>> >>>> >>>> -- >>>> Fernando Almeida >>>> www.fernandoalmeida.net >>>> >>>> -- >>>> 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org. >>>> To unsubscribe from this group, send email to >>>> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>>> For more options, visit https://groups.google.com/groups/opt_out. >>>> >>>> >>>> >>> >>> >>> >>> -- >>> ------------------------------------------------------------- >>> visit my blog at http://jimlabs.heroku.com >>> >>> -- >>> 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>> To unsubscribe from this group, send email to >>> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >>> For more options, visit https://groups.google.com/groups/opt_out. >>> >>> >>> >> >> >> >> -- >> Fernando Almeida >> www.fernandoalmeida.net >> >> -- >> 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >> To unsubscribe from this group, send email to >> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >> For more options, visit https://groups.google.com/groups/opt_out. >> >> >> > > > > -- > ------------------------------------------------------------- > visit my blog at http://jimlabs.heroku.com > > -- > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > For more options, visit https://groups.google.com/groups/opt_out. > > >-- Fernando Almeida www.fernandoalmeida.net -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.