Sha256: c7cc966b9af93df1472a16c7a59797e1f159d4538886f889d6e4a3acc0ee1e41

Contents?: true

Size: 1.98 KB

Versions: 23

Compression:

Stored size: 1.98 KB

Contents

# encoding: UTF-8

# 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.

class UsersController < ApplicationController

  load_and_authorize_resource # cancan magic

  def index
    @users = User.find(:all)

    respond_to do |format|
      format.html # index.html.erb
      format.xml  { render :xml => @users }
    end
  end

  def new
    @user = User.new

    respond_to do |format|
      format.html # new.html.erb
      format.xml  { render :xml => @user }
    end
  end

  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

  def edit
    @user = User.find(params[:id])
  end

  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

  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

end

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
iqvoc-3.2.11 app/controllers/users_controller.rb
iqvoc-3.2.10 app/controllers/users_controller.rb
iqvoc-3.2.9 app/controllers/users_controller.rb
iqvoc-3.2.8 app/controllers/users_controller.rb
iqvoc-3.5.7 app/controllers/users_controller.rb
iqvoc-3.5.6 app/controllers/users_controller.rb
iqvoc-3.5.5 app/controllers/users_controller.rb
iqvoc-3.5.4 app/controllers/users_controller.rb
iqvoc-3.2.7 app/controllers/users_controller.rb
iqvoc-3.5.3 app/controllers/users_controller.rb
iqvoc-3.5.2 app/controllers/users_controller.rb
iqvoc-3.5.1 app/controllers/users_controller.rb
iqvoc-3.5.0 app/controllers/users_controller.rb
iqvoc-3.4.0 app/controllers/users_controller.rb
iqvoc-3.3.4 app/controllers/users_controller.rb
iqvoc-3.3.3 app/controllers/users_controller.rb
iqvoc-3.3.2 app/controllers/users_controller.rb
iqvoc-3.3.1 app/controllers/users_controller.rb
iqvoc-3.3.0 app/controllers/users_controller.rb
iqvoc-3.2.6 app/controllers/users_controller.rb