Generic-user-small RyanL 8 posts

Thanks for the great episode on many_to_many relationships and scopes. Do you have any resources that detail how to create the controllers and views to create showings with movies and add them to Theaters?

 
Generic-user-small RyanL 8 posts

Ok, in terms of this screen cast

movie has_many theaters :through showings
theaters has_many movies:through showigns

in order to to populate theather with movies, is this the process?

1 create the movie with title and run time

2 create a theater with name

3 create a showing for each movie in a theater by a collection select for the movie a collection select for the theater add the start and end dates

this way, you can access all movies in a theater by theater.showing.movie or theater.showings.each do |showing|

The result is you that you create multiple showings, but you only create a movie, thus you do not have to create multiple copies of a movie if it is playing in multiple theaters.

Is that an accurate understanding? Or is there a better way to create a showing?

 
Ryan_bates_cropped_small Ryan Bates 25 posts

Yep, it looks like you have the right idea. Each time you want to add a movie to a theater, you can create a Showing model. One way to do this, as you mentioned, is to have a form for creating a showing and select menus for choosing the theater and movie it belongs to.

An alternative is to create multiple showings the same time you create a movie. This is quite a bit more complicated, but you can see an example of this in the source code for the Validating Models episode. You can also see my recipe on this in the Advanced Rails Recipe book.

 
Generic-user-small RyanL 8 posts

Thanks for replying, Ryan, I will check out the the new episode and take a look at the recipe book. I’ve been thinking about picking that up anyway. It will be good to know how to add showings through movie. Entering a form for showing is better than making a new movie each time it is playing, but if you can bypass a showing form and just create movies and theaters, all the better!

4 posts, 2 voices