Home Runsack gem, scope, date range , menu
Reply: 0

Runsack gem, scope, date range , menu

katia Published in 2018-01-05 15:18:42Z

I have a model Signal with nested models Steps

I want to implement a search method to:

-[1] select a date range from a menu (e.g. all Signal related to the year 2018) [the date is saved in the Step as: yyyymmdd type=date]

-[2] look for text related to note or name insert in the search_field.

In the view:

{ class:"form-inline pull-right" } do |f| %> 'Find notes or name', class: "form-control", style: "width:400px" %>

In the Signal controller I have: def index @q = Signal.ransack(params[:q]) @signals = @q.result(distinct: true).includes(:signal_steps) end

In the Signal model I have:

scope :signal_steps_date, ->(signal_steps_date) { where("date >= ? OR date <= ?", DateTime.new(signal_steps_date, 1, 1), DateTime.new(signal_steps_date, 12, 31)) }

private def self.ransackable_scopes(auth_object = nil) %i(adr_signal_steps_date) end

I don't receive any errors, the search_field works, The urls seams correct with the requested field [2018,remember]: the debug doesn't go trought the scope. The year is not taken into consideration :( I'm missing something

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.332944 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO