mileszs
1/20/2012 - 8:07 PM

gistfile1.rb

# Let's say current_user = the currently logged in user

def update
  user = User.find(params[:id])
  if current_user.superadmin?
    # this is adding stuff to the user's metaclass, which doesn't affect any other User objects
    class << user
      attr_accessible :email, :password, :password_confirmation, :this, :that, :superadmin
    end
  end
  # ... save and redirect and stuff
end

# If you've wandered on to this gist without context, rest assured I am aware 
# this is probably not the best method for its end. It is, however, a lot of fun.