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

matlab - error with cyclic autocorrelation function -

django - (fields.E300) Field defines a relation with model 'AbstractEmailUser' which is either not installed, or is abstract -

c# - What is a good .Net RefEdit control to use with ExcelDna? -