RailsApps/rails3-mongoid-devise

Want to make admin to create other users and edit other users account

regmiprem opened this issue · 1 comments

I am using Devise with cancan ,Bootstrap with rolify.
Here i make edit of user account to admin and it is done by makin update method
def update
authorize! :update, @user, :message => 'Not authorized as an administrator.'
@user = User.find(params[:id])
params[:user].delete(:password) if params[:user][:password].blank?
params[:user].delete(:password_confirmation) if params[:user][:password].blank? and params[:user][:password_confirmation].blank?
if @user.update_attributes(params[:user])
redirect_to users_path, :notice => "User updated."
else
redirect_to users_path, :alert => "Unable to update user."
end
end
This codes work but it does not works for Changing role of the users
if @user.update_attributes(params[:user], :as => :admin) it works for role But not update
if @user.update_attributes(params[:user])it works for update but not roles. Any idea to implement this both situation?

This is a good question for Stack Overflow. The rails3-mongoid-devise example application does not include CanCan or Rolify.