我在需要的模型中有一段代码,但这会破坏 RailsAdmin:
class Item < ActiveRecord::Base
serialize :properties, ActiveRecord::Coders::Hstore
end
由于我还没有找到解决问题的解决方案,我打算只在用户不是管理员时运行这行代码:
在控制器中,我可以通过调用:
unless current_user.role?("Admin") # CanCan is installed
我怎样才能在 Item 模型中实现这样的东西?还是有更好的方法(我有一种感觉)?