Hi, ''m new to Rails. I tried using _path and _url with link_to helper method but it doesnt work for me. Does anyone know what can be the issue? my code is <h1>Hello Rails</h1> <%= flash[:notice] %> <%= link_to ''Show Blog'', posts_url %> Post is my controller The error ''m getting is undefined local variable or method `posts_url'' for #<ActionView::Base: 0x102b23d> Thanks in advance --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Hello Ashit, If you run "rake routes" in your project directory you''ll see what routes are available. Also, the singular vs plural question needs to be considered here. Typically: The model has a singular name - models/path.rb The controller has a plural name - controllers/paths_controller.rb The view has a plural name - views/paths/edit.html.erb So a url for your controller would typically be: paths_url Rick On Nov 23, 12:03 pm, Ashit Vora <a.k.v...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hi, > ''m new to Rails. > I tried using _path and _url with link_to helper method but it doesnt > work for me. > > Does anyone know what can be the issue? > my code is > > <h1>Hello Rails</h1> > <%= flash[:notice] %> > <%= link_to ''Show Blog'', posts_url %> > > Post is my controller > > The error ''m getting is > undefined local variable or method `posts_url'' for #<ActionView::Base: > 0x102b23d> > > Thanks in advance--~--~---------~--~----~------------~-------~--~----~ 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
"rake routes" really becomes your friend here as you are able to take a look at everything that will work. Trust me, just run it and look over the output to see where you might be going wrong. On Nov 23, 4:03 pm, Ashit Vora <a.k.v...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hi, > ''m new to Rails. > I tried using _path and _url with link_to helper method but it doesnt > work for me. > > Does anyone know what can be the issue? > my code is > > <h1>Hello Rails</h1> > <%= flash[:notice] %> > <%= link_to ''Show Blog'', posts_url %> > > Post is my controller > > The error ''m getting is > undefined local variable or method `posts_url'' for #<ActionView::Base: > 0x102b23d> > > Thanks in advance--~--~---------~--~----~------------~-------~--~----~ 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Hi Ashit. Another thing that you can do is test out the various URL and path helpers in your app''s console. For example: $ script/console Loading development environment (Rails 2.1.0)>>?> app.photos_url => "http://www.example.com/photos">>?> app.photos_path => "/photos">>?> quit Cheers, Nick --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Nick Hoffman wrote:> Hi Ashit. Another thing that you can do is test out the various URL > and path helpers in your app''s console. For example: > > $ script/console > Loading development environment (Rails 2.1.0) >>> > ?> app.photos_url > => "http://www.example.com/photos" >>> > ?> app.photos_path > => "/photos" >>> > ?> quit > > Cheers, > Nickgood one Thanks -- 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---