I am not using a plugin and used instead the tutorial http://ruby.railstutorial.org/chapters for my administration. However the issue I am having is the following
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
What I would like also is if you are admin_user to then be able to edit, and update the customer. But because of correct_user been used, It doesn’t work
I have try the following
def correct_customer
@customer = Customer.find(params[:id])
redirect_to(root_path) unless current_customer?(@customer) || customer.admin?
end
But then I have an undefined customer. What would be my best approach to allow the user if admin to modify a selected customer.
The error occurs if i click the a customer#edit (not me)
NameError in CustomersController#edit
undefined local variable or method `customer' for #<CustomersController:0xa51fd60>
Rails.root: /home/jean/rail/map
i think you’ve meant