ruby on rails - ransack when i am use sort_link ignores search criteria -
good evening.
i have code, when hit sort link ignores search criteria , sends event.all sort criteria
i think problem on first load sets variables path , params empty
well problem on lines wih ends
unless params[:q]
controller
def index @q = event.search(params[:q]) #predefined search items if no search @ @q.datum_eq=date.current() unless params[:q] @q.cil_id_eq=sklad.first.id unless params[:q] @events = @q.result end
view
<%= search_form_for @q ,:html => { :class => "form-inline" } |f| %> <%= f.search_field :datum_eq, class: 'form-control' %> <%=f.collection_select :cil_id_eq, sklad.all, :id, :name,{},{class: "form-control"}%> <%= sort_link(@q, :dodavatel) %> end
params when went properly
<actioncontroller::parameters {"utf8"=>"✓", "q"=>{"datum_eq"=>"20.04.2017", "cil_id_eq"=>"1"}, "controller"=>"events", "action"=>"index"} permitted: false>
improperly params
<actioncontroller::parameters {"q"=>{"s"=>"dodavatel asc"}, "controller"=>"events", "action"=>"index"} permitted: false>
Comments
Post a Comment