Hello, I am with my first steps in Rails creating an app for a VideoClub, I need to know if a movie is available or if it is already borrowed. In the Movie model there is an availability attribute which is a boolean. Would I have to create a method on the model to access that attribute and see if it's true and then use what I get from there in another method on the controller so I can display a list of available and borrowed ones?
It confuses me what goes in the model and what goes in the control.
If you need to show both available and unavailable, just call
Movie.all
in your controller action and then in the view show one text or another depending on the value ofavailability
. Now, if you only need to display the available ones, in your model you can create a scope:and then in the controller you call
Movie.available
.