Rake routes shows paths, but views can't find them

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?

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)%>

doh! thanks!

Michael B. 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)%>

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs