I am trying to pass my ransack params[:q] object to my presenter class but getting the No Ransack::Search object was provided to search_form_for!
error.
Here is my sample code
client_managers_widgets/index.html.haml
= search_form_for @search, :url => admin_client_managers_widgets_path do |f|
= render :partial => "admin/share/filter_wrapper", :locals => { :f => f, :filter=> "admin/client_managers_widgets/filters/redemption_filter" }
_redemption_filter.html.haml
%table.filters
%tr
%td
= f.label :created_at_gteq, "Select Period"
= f.select :created_at_gteq, { "Start Till Date" => "", "This Year" => Date.today.beginning_of_year, "Last Month" => 1.month.ago.beginning_of_month, "This Month" => Date.today.beginning_of_month }
%td
= f.label :user_telecom_circle_regional_managers_id_eq, "Region"
= f.collection_select :user_telecom_circle_regional_managers_id_eq, @telecom_regions.select_options, :id, :region, {:include_blank => t(:all)}, :class => 'telecom_circle_regional_managers_id_eq'
%tr
%td
= f.label :created_at_date_gteq,"Select Custome Time"
= f.text_field :created_at_date_gteq, :class => 'datepicker input-small'
= f.label "-", :class=>"to"
= f.text_field :created_at_date_lteq, :class => 'datepicker input-small'
controller => client_managers_widgets
def index
@client_manager_dashboard = ClientManagerDashboard.new(current_admin_user, search_params)
# .
# .
# .
end
private
def search_params
params[:q]
end
presenter => client_manager_dashboard
class ClientManagerDashboard
def initialize(admin_user, search_params)
@current_ability = Ability.new(admin_user)
@search_params = search_params
end
def get_users
@search = User.joins(:client).where(clients: {id: clients}).search(search_params)
@users = @search.result
end
private
def current_ability
@current_ability
end
def search_params
@search_params
end
end
Aucun commentaire:
Enregistrer un commentaire