I add the following override for a controller that I inherit from a gem (Spree):
module Spree
module Admin
UsersController.class_eval do
def index
if params[:role].present?
included_users = Spree::User.joins(:role_users).
where( spree_role_users: { role_id: params[:role] } ).map(&:id)
flash[:notice] = "Filtered in #{included_users.count} users"
@users = @users.where(id: included_users)
end
end
end
end
end
Basically, it filters by an additional parameter on the Admin::UsersController
controller. The source for that controller in the gem doesn't actually define the index
method, so mine just gets called instead.
Now, this works perfectly well in development. However, in production, this method never gets called.
Is there something about class_eval
that I'm not getting here? Shouldn't things like this work basically the same in production as they do in development?
Thanks for any help.