Class: UsersController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- UsersController
- Defined in:
- app/controllers/users_controller.rb
Overview
Copyright 2011 innoQ Deutschland GmbH
Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Instance Method Summary collapse
Instance Method Details
#create ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'app/controllers/users_controller.rb', line 39 def create @user = User.new(params[:user]) respond_to do |format| if @user.save flash[:notice] = I18n.t('txt.controllers.users.successfully_created') format.html { redirect_to users_path } else format.html { render :action => "new" } end end end |
#destroy ⇒ Object
71 72 73 74 75 76 77 78 79 |
# File 'app/controllers/users_controller.rb', line 71 def destroy @user = User.find(params[:id]) @user.destroy respond_to do |format| format.html { redirect_to users_path } format.xml { head :ok } end end |
#edit ⇒ Object
52 53 54 |
# File 'app/controllers/users_controller.rb', line 52 def edit @user = User.find(params[:id]) end |
#index ⇒ Object
21 22 23 24 25 26 27 28 |
# File 'app/controllers/users_controller.rb', line 21 def index @users = User.find(:all) respond_to do |format| format.html # index.html.erb format.xml { render :xml => @users } end end |
#new ⇒ Object
30 31 32 33 34 35 36 37 |
# File 'app/controllers/users_controller.rb', line 30 def new @user = User.new respond_to do |format| format.html # new.html.erb format.xml { render :xml => @user } end end |
#update ⇒ Object
56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'app/controllers/users_controller.rb', line 56 def update @user = User.find(params[:id]) respond_to do |format| if @user.update_attributes(params[:user]) flash[:notice] = I18n.t('txt.controllers.users.successfully_updated') format.html { redirect_to edit_user_path(:id => @user) } format.xml { head :ok } else format.html { render :action => "edit" } format.xml { render :xml => @user.errors, :status => :unprocessable_entity } end end end |