I apologize for the vagueness of my first post, which happened about four or five days ago. I have since gotten over the problem that was facing me then, but am having trouble with another, thornier problem. It goes thusly:
I have three classes, Deck, Card and Hero. Deck should belong to hero and have many cards, while hero should have many decks and have many cards through decks. Card belongs to Deck. My idea was this: that whenever someone wants to add a new card to a Deck, he would supply the name (and possibly further details) of a particular card, and then a new Card model would be created, associated with the particular Deck that it was created upon. I had thought of creating a new form, apart from the normal forms created by Rails' scaffolding, to take in these details, create a new Card, and then "attach" it to the relevant Deck. However, I'm simply stumped as to how to do this. Would I need to use something other than "Submit" in my form?
One possibility that suggested itself to me was to have a button on the "Show a particular deck" view, which when clicked would invoke the create method of Card. However, attempts to make this work have only resulted in the app misinterpreting my commands and trying to go to cards/index instead. Turning cards/create into a Module was also suggested, but that seems like it would suffer from scope problems, since that method requires card_params as an input, which is another method within Card. In addition, card_params requires access to params, which probably wouldn't work if accessed from Deck, since Deck does not have the same parameters as Card. Does anyone have any idea of how such a problem should be addressed? I will provide code on request.