movies_controller.txt 4.39KB 246 downloadsHello,
I'm a newbie on Rails (use version 4.0.1) and i would like to know and understand how to pass some params who has been selected from selected lists box (in the html view) via a push button to the controller of the same page view.
Like that, i could view on a list, for example, all movies, with "style=Action-movies AND date between 1990 & 2000", "sort by TITLE".
from now, i'm able to
_ create a movie with all params i need (and select list with enum fonction from MySQL...)
_ update and show one of them
_ view a list sort by titles (and integrate with the perfect paginate gem... very nice !)
_ see my selected boxes for sort and selection
but can not be able to make the link between this selection options and my list of movies...
i make follow two files: my movies_controller and my index view (sure that can be more clear for the problem)
movies_controller.txt 4.39KB 246 downloads
but here is an example of my method inside movies_controller:
def show_sort raise CanCan::AccessDenied unless can?(:read,Movie) puts "=dddddddd" @movies = Movie.order(:choose).page(params[:page]).per(6) render 'index' end
and here is the part of routes file linked to the method/action call
resources :movies do get 'show_sort', on: :member end
(impossible to upload the view file... so i need write here a part of it for example show)
<section id='list_movie'> <%= paginate @movies %><div id="info_movies"> <%= page_entries_info @movies %></div> <div class="choose"><table> <colgroup> <col style="width:10%"> <col style="width:20%"> <col style="width:40%"> <col style="width:10%"> <col style="width:20%"> <tr> <td>Sort by : </td> <td> <%= select(:choose, ["",:title, :date, :note], ["","title", "date of parution", "note"] ) %></td> <td> </td> <td>Only for : </td> <td><%= select(:style_select, @movies.find(id="1").enum_all(:style), @movies.find(id="1").enum_all(:style) ) %></td> </tr><tr> <td>From : </td> <td><%= select(:date_from_select, 1950..Time.now.year, 1950..Time.now.year ) %></td> <td colspan="2"> </td> <td><%= select(:note_select, @movies.find(id="1").enum_all(:note), @movies.find(id="1").enum_all(:note) ) %></td> </tr><tr> <td>To : </td> <td><%= select(:date_to_select, 1950..Time.now.year, 1950..Time.now.year ) %></td> <td colspan="3"> </td> </tr></table> <%= button_to "Sort now", show_sort_movie_path(@movies), :method => 'get' %></div>