Rails pattern to build new object related to current view/model
Rails newb question: Say I'm currently viewing the show.html
for one of my classes(Dog
). This class has_many Flea(s). If I put a "add new flea" link that links to new_flea_path
(/fleas/new) when clicked it will build a new Flea (`@flea = Flea.new) and render flea's new.html.haml with its form fields...
But, how/where do I automatically pass in the dog_id that the flea needs to referen开发者_运维问答ce?
is this a routes issue? maybe /dog/3/flea/new
is what I need to handle in routes? or is this a controller thing?
What you are looking for is referred to as "Nested Resources". you can read up on them here
精彩评论