Ok guys, so I’m making a scheduler.
So I have two tables so far,
Shows with “title:string” and “description:text” and I also have
ShowTime; with “show_id:integer”, “day:string”, and “show_time:time”.
I did the has_many, and belongs_to, I honestly do not know where to go from here on,
I want a user to be able to add the times when creating a new show. What would I do? I was looking at some rails associations documentations, seems like I would be making something like,
@showtime = @shows.showtimes.create(:show_id => show.id, :day => DAY, :show_time => TIME)
Notice I put just DAY and TIME, because I also honestly don’t know how I’ll fetch this data.
It really depends on your interface. But for simplicity, let’s assume you provided two select boxes for selecting day and time, and have to add
ShowTimeone by one.And assume you have rest resources:
The form: (given a @show object created already)
You should provide your best way to generate the
day&show_timearrays. They are in the following structure:[["Text", "value"], ["Text", "value"]]which will generate something like:
<option value="value">Text</option>After the form is submitted, in your create action: