Hey there,
I’m in the muck of a major rails project, and need a bit of advice. Google isn’t much help in this case, so I came here.
I’m trying to set up a URL structure as follows:
where the user has_many posts and the post belongs_to user. I’m using the friendly_id plugin to enable easy lookup with the user’s username, and I would like to have the blog paths automatically retrieved, instead of getting a path error (as such):
ActionView::TemplateError (post_url failed to generate from {:controller=>“posts”, :user_id=>#<Post id: 1, user_id: 5, title: “Rock and Roll”, body: “This is my blog post body.”, created_at: “2009-12-03 15:40:06”, updated_at: “2009-12-03 15:40:06”>, :action=>“show”}, expected: {:controller=>“posts”, :action=>“show”}, diff: {:user_id=>#<Post id: 1, user_id: 5, title: “Rock and Roll”, body: “This is my blog post body.”, created_at: “2009-12-03 15:40:06”, updated_at: “2009-12-03 15:40:06”>}) on line #3 of app/views/posts/edit.html.erb:
One strategy that I’ve tried is to lookup the user, and then filter the posts by that user, but no luck thus far on making the paths work. Before I write my own link helpers, do you have any ideas?
Thanks!
Nicholas Young
nicholas@nicholaswyoung.com
615.727.2645 (Cell)
615.829.6687 (Main)
http://nicholaswyoung.com