我没有使用插件,而是使用教程http://ruby.railstutorial.org/chapters进行管理。然而,我遇到的问题如下
class UsersController < ApplicationController
before_filter :signed_in_user, only: [:index, :edit, :update, :destroy]
before_filter :correct_user, only: [:edit, :update]
before_filter :admin_user, only: :destroy我也想是如果你是admin_user然后能够编辑,并更新客户。但由于correct_user已被使用,它不能工作
我尝试过以下几种方法
def correct_customer
@customer = Customer.find(params[:id])
redirect_to(root_path) unless current_customer?(@customer) || customer.admin?
end但是我有一个不确定的客户。什么是我最好的方法,让用户,如果管理员修改一个选定的客户。
如果我单击a customer#edit (而不是我),则会出现错误
NameError in CustomersController#edit
undefined local variable or method `customer' for #<CustomersController:0xa51fd60>
Rails.root: /home/jean/rail/map发布于 2012-08-14 01:08:29
我想你的意思是
redirect_to(root_path) unless current_customer?(@customer) || @customer.admin?https://stackoverflow.com/questions/11938501
复制相似问题