def index
@marker_grid = MarkersGrid.new(params.fetch(:markers_grid, {}).merge(current_user: current_user)) do |scope|
scope.page(params[:page])
end
end
So how to add dynamic data to the default option?
eg.
filter(:user_id, :enum, header: -> { t('.user') }, select: :users_collection, default: :who_u_are, include_blank: 'All', multiple: true, input_html: 'select2')
def users_collection
User.where(id: user_id).map { |u| [u.name, u.id] }
end
def who_u_are
User.where(id: current_user).map { |u| [u.name, u.id] }
end
In MarkersController
In MarkersGrid
So how to add dynamic data to the default option? eg. filter(:user_id, :enum, header: -> { t('.user') }, select: :users_collection, default: :who_u_are, include_blank: 'All', multiple: true, input_html: 'select2')
def users_collection User.where(id: user_id).map { |u| [u.name, u.id] } end
def who_u_are User.where(id: current_user).map { |u| [u.name, u.id] } end
Thanks