I froze to Rails 2.0.1 and I''m creating a simple nested blog with map.resources :blogs do |blog| blog.resources :posts end in routes.rb If I run rake routes, it shows a route to blog_posts blog_posts GET /blogs/:blog_id/posts {:controller=>"posts", :action=>"index"} however if I use blog_posts in a view, for example <%= link_to "manage blog", blog_posts(@blog)%> I keep getting the error undefined method `blog_posts'' for #<ActionView::Base:0x81bda0c> Any ideas of what I could be 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-/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 -~----------~----~----~----~------~----~------~--~---
Michael Bleigh
2007-Dec-12 20:41 UTC
Re: Rake routes shows paths, but views can''t find them
You need to use blog_posts_path or blog_posts_url. Either will work with your link_to, but path is preferable (to me at least): <%= link_to "manage blog", blog_posts_path(@blog)%> On Dec 12, 2007, at 3:40 PM, Rodrigo Etcheto wrote:> > I froze to Rails 2.0.1 and I''m creating a simple nested blog with > > map.resources :blogs do |blog| > blog.resources :posts > end > > in routes.rb > > If I run rake routes, it shows a route to blog_posts > > blog_posts GET /blogs/:blog_id/posts {:controller=>"posts", > :action=>"index"} > > however if I use blog_posts in a view, for example > > <%= link_to "manage blog", blog_posts(@blog)%> > > I keep getting the error > > undefined method `blog_posts'' for #<ActionView::Base:0x81bda0c> > > Any ideas of what I could be 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-/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 -~----------~----~----~----~------~----~------~--~---
Rodrigo Etcheto
2007-Dec-12 20:43 UTC
Re: Rake routes shows paths, but views can''t find them
doh! thanks! Michael Bleigh wrote:> You need to use blog_posts_path or blog_posts_url. Either will work > with your link_to, but path is preferable (to me at least): > > <%= link_to "manage blog", blog_posts_path(@blog)%>-- 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 -~----------~----~----~----~------~----~------~--~---