Sha256: 1db2fc819fc2740d05730f616512b71041e27fb8e4ee46f0921a3bd31ae6c7b0
Contents?: true
Size: 1.06 KB
Versions: 7
Compression:
Stored size: 1.06 KB
Contents
class Admin::UserController < Admin::AbstractModelController model_class User only_allow_access_to :index, :new, :edit, :remove, :when => :admin, :denied_url => {:controller => 'page', :action => :index}, :denied_message => 'You must have administrative privileges to perform this action.' def preferences @user = current_user if valid_params? handle_new_or_edit_post( :redirect_to => page_index_url, :saved_message => 'Your preferences have been saved.' ) else announce_bad_data end end def remove if current_user.id.to_s == params[:id].to_s announce_cannot_delete_self redirect_to user_index_url else super end end private def announce_cannot_delete_self flash[:error] = 'You cannot delete yourself.' end def announce_bad_data flash[:error] = 'Bad form data.' end def valid_params? hash = (params[:user] || {}).symbolize_keys (hash.keys - [:password, :password_confirmation, :email]).size == 0 end end
Version data entries
7 entries across 7 versions & 1 rubygems