ruby-on-rails – ActiveAdmin:如何覆盖索引控制器操作:nil的
我正在尝试覆盖ActiveAdmin控制器的索引操作,以显示current_user的结果而不是所有结果.
controller do def index @user_tasks = UserTask.where(:user_id => current_user.id).page(params[:page]) end end 访问ActiveAdmin时,抛出异常: ActionView::Template::Error (undefined method `base' for nil:NilClass): 1: render renderer_for(:index) 我正在使用rails 3.1和最新的ActiveAdmin版本. gem“activeadmin”,:git => ‘https://github.com/gregbell/active_admin.git’. 解决方法
这不再是必需的.
ActiveAdmin 0.4.4现在支持范围查询而不覆盖此方法.
ActiveAdmin.register Post do scope_to :current_user # or if the association doesn't have the default name. # scope_to :current_user,:association_method => :blog_posts end (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |