I want to skip validation when I am trying to edit user as admin.
Model
class User
...
attr_accessible :company_id, :first_name, :disabled, as: :admin
Controller
class Admin::UsersController
...
def update
@user = User.find(params[:id])
@user.update_attributes(params[:user], as: :admin)
redirect_to edit_admin_user_path(@user), :notice => "User Account Updated"
end
So I tried to change update
action to
def update
@user = User.find(params[:id])
@user.attributes = params[:user]
@user.save(validate: false)
redirect_to edit_admin_user_path(@user), :notice => "User Account Updated"
end
But then I dont have access to set :disabled
and :company_id
attributes because i dont know where to set as: :admin