S
S
Silentium20152016-10-26 09:15:52
Ruby on Rails
Silentium2015, 2016-10-26 09:15:52

How to filter objects in rails?

There is a filter on the page with different parameters, I use gem 'ransack'
controller

def index
   @search = Restaurant.search(params[:q])
   @restaurants = @search.result.where(:publish => true, :status => 1)
end

index
<%= search_form_for @search, id: 'catalog_filter' do |f| %>
  ...
<% end %>

1 question
How can I filter by object rating? I use gem 'ratyrate'
2 question
How can I filter by price. Am I using jqueryui?
<div class="slider"></div>
<%= f.search_field :check, id: 'hidden' %>

$(".slider" ).slider({
        animate: true,
        range: "min",
        value: 970,
        min: 250,
        max: 2700,
        step: 1,
        slide: function( event, ui ) {
            $( "#slider-result" ).html( ui.value );
        },
        change: function(event, ui) {
            $('#hidden').attr('value', ui.value);

        }
    })

AAVbB.png

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question