szimek
2010-Apr-22 15:49 UTC
How to automatically set params based on passed object when generating a route?
Hi, having i.e. a post model that has many categories - is it possible for member routes like i.e. post_path(post) to generate path like "/ posts/:post_category_name/:post_id" without manually passing the category param? Does anyone know if there''s a gem or if I can simply override the post_url method to automatically set category from post object? The best I could get right now is post_path(post.category, post), but while it doesn''t look awful it still breaks all links in my app where most of the time I generate links using link_to(post.title, post). Cheers, Szymon -- 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.