Class: UsersController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- UsersController
- Defined in:
- lib/templates/app/controllers/users_controller.rb
Instance Method Summary collapse
-
#create ⇒ Object
POST /users POST /users.xml.
-
#destroy ⇒ Object
DELETE /users/1 DELETE /users/1.xml.
-
#edit ⇒ Object
GET /users/1/edit.
-
#index ⇒ Object
GET /users GET /users.xml.
-
#new ⇒ Object
GET /users/new GET /users/new.xml.
-
#show ⇒ Object
GET /users/1 GET /users/1.xml.
-
#update ⇒ Object
PUT /users/1 PUT /users/1.xml.
Instance Method Details
#create ⇒ Object
POST /users POST /users.xml
42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/templates/app/controllers/users_controller.rb', line 42 def create @user = User.new(params[:user]) respond_to do |format| if @user.save format.html { redirect_to(@user, :notice => 'User was successfully created.') } format.xml { render :xml => @user, :status => :created, :location => @user } else format.html { render :action => "new" } format.xml { render :xml => @user.errors, :status => :unprocessable_entity } end end end |
#destroy ⇒ Object
DELETE /users/1 DELETE /users/1.xml
74 75 76 77 78 79 80 81 82 |
# File 'lib/templates/app/controllers/users_controller.rb', line 74 def destroy @user = User.find(params[:id]) @user.destroy respond_to do |format| format.html { redirect_to(users_url) } format.xml { head :ok } end end |
#edit ⇒ Object
GET /users/1/edit
36 37 38 |
# File 'lib/templates/app/controllers/users_controller.rb', line 36 def edit @user = User.find(params[:id]) end |
#index ⇒ Object
GET /users GET /users.xml
4 5 6 7 8 9 10 11 |
# File 'lib/templates/app/controllers/users_controller.rb', line 4 def index @users = User.all respond_to do |format| format.html # index.html.erb format.xml { render :xml => @users } end end |
#new ⇒ Object
GET /users/new GET /users/new.xml
26 27 28 29 30 31 32 33 |
# File 'lib/templates/app/controllers/users_controller.rb', line 26 def new @user = User.new respond_to do |format| format.html # new.html.erb format.xml { render :xml => @user } end end |
#show ⇒ Object
GET /users/1 GET /users/1.xml
15 16 17 18 19 20 21 22 |
# File 'lib/templates/app/controllers/users_controller.rb', line 15 def show @user = User.find(params[:id]) respond_to do |format| format.html # show.html.erb format.xml { render :xml => @user } end end |
#update ⇒ Object
PUT /users/1 PUT /users/1.xml
58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/templates/app/controllers/users_controller.rb', line 58 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.xml { head :ok } else format.html { render :action => "edit" } format.xml { render :xml => @user.errors, :status => :unprocessable_entity } end end end |