I have the usual: config/routes.rb: NewApp::Application.routes.draw do match(''blahs/:item'' => ''blahs#show'', :constraints => { :item => /.*/ }) end app/view/blahs/show.html.erb: <%= link_to "blah", blahs_path(9999) %> But I''m getting this error: undefined method `blahs_path'' for #<#<Class:0x007f96083474c0>:0x007f960509b288> I''ve tried blah_path, blahs_path, blah_url, and blahs_url. What am I doing wrong? I''m using Rails 3.2. This is my first Rails 3.2 app but I''ve used Rails 2.x for a long time. I can''t figure out what I''m doing wrong. -- Posted via http://www.ruby-forum.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 this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On 6 June 2012 14:34, Perry Smith <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> I have the usual: > > config/routes.rb: > NewApp::Application.routes.draw do > match(''blahs/:item'' => ''blahs#show'', :constraints => { :item => > /.*/ }) > end > > app/view/blahs/show.html.erb: > <%= link_to "blah", blahs_path(9999) %> > > But I''m getting this error: > undefined method `blahs_path'' for > #<#<Class:0x007f96083474c0>:0x007f960509b288> > > I''ve tried blah_path, blahs_path, blah_url, and blahs_url. > > What am I doing wrong? > > I''m using Rails 3.2. This is my first Rails 3.2 app but I''ve used Rails > 2.x for a long time. I can''t figure out what I''m doing wrong.I believe that if you want to use blah_path(id) (it should be blah not blahs) then you have to have resources :blahs in your routes. If you have not got resourceful routes then you can still say blah_path( @blah ). See the Rails Guide on Routing. I have to say I am not 100% certain about the above however. Colin -- 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 this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Thanks. I checked http://guides.rubyonrails.org/routing.html first. The code I have, to my eyes, match the lead examples in sections 1.1 and 1.2. There must be something I''m overlooking. -- Posted via http://www.ruby-forum.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 this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On 6 June 2012 15:33, Perry Smith <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> Thanks. > > I checked http://guides.rubyonrails.org/routing.html first. The code I > have, to my eyes, match the lead examples in sections 1.1 and 1.2. > There must be something I''m overlooking.Please quote the previous message when replying so that it is easier to follow the thread. Anyone reading this will now have to look back at previous messages to check your code (myself included). 1.1 of the guide does not include the use of _path, 1.2 has the code <%= link_to "Patient Record", patient_path(@patient) %> note that this uses @patient as the parameter, not an id as in your example. Section 2.3 shows the use of photo_path(id) where resourceful routes are used as I said in my previous post, but you have not specified a resourceful route. Colin -- 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 this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Colin Law wrote in post #1063357:> On 6 June 2012 15:33, Perry Smith <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote: >> Thanks. >> >> I checked http://guides.rubyonrails.org/routing.html first. The code I >> have, to my eyes, match the lead examples in sections 1.1 and 1.2. >> There must be something I''m overlooking. > > Please quote the previous message when replying so that it is easier > to follow the thread. Anyone reading this will now have to look back > at previous messages to check your code (myself included). > > 1.1 of the guide does not include the use of _path, 1.2 has the code > <%= link_to "Patient Record", patient_path(@patient) %> > note that this uses @patient as the parameter, not an id as in your > example. > > Section 2.3 shows the use of photo_path(id) where resourceful routes > are used as I said in my previous post, but you have not specified a > resourceful route. > > ColinSorry... I''m reading this from the forum interface and didn''t consider people reading it via email. You are correct. I added resources :pogos to routes.rb and now I can do: <%= link_to "pogo", pogo_path(1234) %> in my view. I thought resources were just a batch of named routes and I thought what I did before was a named route. I need to go check on that. What confuses me is that blah_path is not even defined. It seems like if it needed a particular type of argument, then the error would be inside blah_path -- not in the code trying to find the blah_path method. I wonder if Rails is eating the top of the exception stack which might help me understand what is really happening in this case. Thank you for your time. -- Posted via http://www.ruby-forum.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 this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On 6 Jun 2012, at 18:21, Perry Smith <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> Colin Law wrote in post #1063357: >> On 6 June 2012 15:33, Perry Smith <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote: >>> Thanks. >>> >>> I checked http://guides.rubyonrails.org/routing.html first. The code I >>> have, to my eyes, match the lead examples in sections 1.1 and 1.2. >>> There must be something I''m overlooking. >> >> Please quote the previous message when replying so that it is easier >> to follow the thread. Anyone reading this will now have to look back >> at previous messages to check your code (myself included). >> >> 1.1 of the guide does not include the use of _path, 1.2 has the code >> <%= link_to "Patient Record", patient_path(@patient) %> >> note that this uses @patient as the parameter, not an id as in your >> example. >> >> Section 2.3 shows the use of photo_path(id) where resourceful routes >> are used as I said in my previous post, but you have not specified a >> resourceful route. >> >> Colin > > Sorry... I''m reading this from the forum interface and didn''t consider > people reading it via email. > > You are correct. I added > > resources :pogos > > to routes.rb and now I can do: > > <%= link_to "pogo", pogo_path(1234) %> > > in my view. > > I thought resources were just a batch of named routes and I thought what > I did before was a named route. I need to go check on that. > > What confuses me is that blah_path is not even defined. It seems like > if it needed a particular type of argument, then the error would be > inside blah_path -- not in the code trying to find the blah_path method.Did you name the route in your routes file (ie :as => "blah")?> > I wonder if Rails is eating the top of the exception stack which might > help me understand what is really happening in this case. > > Thank you for your time. > > -- > Posted via http://www.ruby-forum.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 this group at http://groups.google.com/group/rubyonrails-talk?hl=en. >-- 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 this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Jeremy W. wrote in post #1063404:> On 6 Jun 2012, at 18:21, Perry Smith <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote: > >>> at previous messages to check your code (myself included). >>> Colin >> <%= link_to "pogo", pogo_path(1234) %> >> >> in my view. >> >> I thought resources were just a batch of named routes and I thought what >> I did before was a named route. I need to go check on that. >> >> What confuses me is that blah_path is not even defined. It seems like >> if it needed a particular type of argument, then the error would be >> inside blah_path -- not in the code trying to find the blah_path method. > > Did you name the route in your routes file (ie :as => "blah")?Thank you. I was just writing a reply with the same info. Originally I did not. Thank you again. -- Posted via http://www.ruby-forum.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 this group at http://groups.google.com/group/rubyonrails-talk?hl=en.