Class: SimpleUser::UsersController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- ApplicationController
- SimpleUser::UsersController
- Defined in:
- app/controllers/simple_user/users_controller.rb
Instance Method Summary collapse
- #authorize_user_manager ⇒ Object
- #create ⇒ Object
- #destroy ⇒ Object
- #edit ⇒ Object
- #index ⇒ Object
- #new ⇒ Object
- #show ⇒ Object
- #update ⇒ Object
Methods inherited from ApplicationController
Instance Method Details
#authorize_user_manager ⇒ Object
80 81 82 83 84 85 |
# File 'app/controllers/simple_user/users_controller.rb', line 80 def if !can? :manage, User flash[:error] = "Access denied" redirect_to root_url end end |
#create ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'app/controllers/simple_user/users_controller.rb', line 40 def create @user = User.new(params[:user]) respond_to do |format| if @user.save logger.debug "SAVE" format.html { redirect_to @user, notice: 'User was successfully created.' } format.json { render json: @user, status: :created, location: @user } else logger.debug "ERROR: #{@user.errors.inspect}" format.html { render action: "new" } format.json { render json: @user.errors, status: :unprocessable_entity } end end end |
#destroy ⇒ Object
70 71 72 73 74 75 76 77 78 |
# File 'app/controllers/simple_user/users_controller.rb', line 70 def destroy @user = User.find(params[:id]) @user.destroy respond_to do |format| format.html { redirect_to users_url } format.json { head :no_content } end end |
#edit ⇒ Object
36 37 38 |
# File 'app/controllers/simple_user/users_controller.rb', line 36 def edit @user = User.find(params[:id]) end |
#index ⇒ Object
9 10 11 12 13 14 15 16 |
# File 'app/controllers/simple_user/users_controller.rb', line 9 def index @users = User.all respond_to do |format| format.html # index.html.erb format.json { render json: @users } end end |
#new ⇒ Object
27 28 29 30 31 32 33 34 |
# File 'app/controllers/simple_user/users_controller.rb', line 27 def new @user = User.new respond_to do |format| format.html # new.html.erb format.json { render json: @user } end end |
#show ⇒ Object
18 19 20 21 22 23 24 25 |
# File 'app/controllers/simple_user/users_controller.rb', line 18 def show @user = User.find(params[:id]) respond_to do |format| format.html # show.html.erb format.json { render json: @user } end end |
#update ⇒ Object
56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'app/controllers/simple_user/users_controller.rb', line 56 def update @user = User.find(params[:id]) respond_to do |format| if @user.update_attributes(params[:user]) format.html { redirect_to @user, notice: 'User was successfully updated.' } format.json { head :no_content } else format.html { render action: "edit" } format.json { render json: @user.errors, status: :unprocessable_entity } end end end |