Queries of records in the bank through date

Asked

Viewed 55 times

0

I’m developing a Ruby sales management system with Rails and the customer needs to consult sales through two calendar dates, which together make up the range of data he wants to be pulled from the bank.

The graphical and functional part is being applied by means of a date helper: <%= select_date(Time.now) %>

My problem is to make this helper really interfere in the table that will appear the data, bringing from the database only the results that are within the range selected by the user.

So that this <%= select_date(Time.now) %> converse with the date columns of my bank, which I would have to add to my code?

1 answer

1


You can use Gem Ransack

On your controller:

def index
  @q = Person.ransack(params[:q])
  @people = @q.result
end

In your view:

<%= search_form_for(@q) do |f| %>
  <%= f.date_field :data_gteq %>
  <%= f.date_field :data_lteq %>

  <%= f.submit %>
<% end %>

Browser other questions tagged

You are not signed in. Login or sign up in order to post.