In my Ruby on Rails application I have a cinema application and am trying to populate a drop down menu with films that have showing dates that are not in the past.
In my _form.html.erb I have this dropdown menu that is trying to use the live_films
method:
<%= f.grouped_collection_select :showing_id, Film.order(:title).live_films, :showings, :title, :id, :showing_times %>
The method is in application_controller:
helper_method :active_menu, :live_films
def live_films
Film.includes(:showings).where.not(showings.show_date < Date.today)
end
I also suspect that my method wouldn't work so I welcome suggestions for getting it to function.
What am I doing wrong?
You should be calling order
on result of live_films
method call as:
<%= f.grouped_collection_select :showing_id, live_films.order(:title), :showings, :title, :id, :showing_times %>
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments