Enter data in rails before controller action -


i have transactions controller , view. when click link "transactions", show transactions.

how add before display transactions such enter start , end dates?

what need ransack gem.

you can add custom filtering mechanism in controller this:

def index   @q = transaction.ransack(params[:q])   @transactions = @q.result(distinct: true) end 

and using in view simple this:

<%= search_form_for @q |f| %>   <%= f.label :start_date %>   <%= f.search_field :created_at_gteq %>    <%= f.label :end_date %>   <%= f.search_field :created_at_lteq %>    <%= f.submit %> <% end %> 

and let filter transaction data using created_at param filter. modify form accordingly if need filter using date/datetime param model.


Comments

Popular posts from this blog

java - Static nested class instance -

c# - Bluetooth LE CanUpdate Characteristic property -

JavaScript - Replace variable from string in all occurrences -