Topic: trouble creating advanced wizard style functionality

I'm fairly new to rails and not sure how to handle this situation. I'm trying to allow the user to create a meeting, add as many locations for the meeting as they'd like, then add as many dates for each of those locations as they'd like in a wizard style form.

I have the first piece working correctly, the user can create the meeting and add as many locations as they like using fields_for the locations (meeting has many locations).

What I'm struggling with is how do I then allow them to add several dates for each location. Adding a date is really creating an record that has a meetingID, a locationID, and two date fields.

A few questions:
1) It seems to me the first piece (creating the meeting and its children locations) will have to be one action (create method in the meeting controller) so that the new location IDs will be available in order to facilitate adding dates for each location is that correct?

2) If that is is the case, what controller/action should adding the dates for each location be in? Another action in the meeting controller? Or in the date controller?

3) Any other advice/guidance is much appreciated!


Last edited by turbo2oh (2013-02-26 17:35:06)

Re: trouble creating advanced wizard style functionality

I'm fairly new to Rails too but I guess a "has through" relationship can be the way to achieve this ( … ssociation and … sociation, ... Something like

    meeting has_many locations 
    meeting has one start_date through location
    meeting has one end_date through location

and of course the opposite associations in the related models

Hope this helps you a bit or at least put you on the right way

Last edited by anso (2013-02-27 05:19:53)

Re: trouble creating advanced wizard style functionality

@anso : thanks, I have the model relationships setup correctly I'm just confused about how to implement it on the controller/view side of things.