Sha256: 82c537fb44fc88573a7326c23fecf2a74c584ff2283d286faa2f5f99fcea9261

Contents?: true

Size: 738 Bytes

Versions: 15

Compression:

Stored size: 738 Bytes

Contents

class UsersController < ApplicationController
  before_filter :authenticate_user!
  after_action :verify_authorized

  def index
    @users = User.all
    authorize User
  end

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

  def update
    @user = User.find(params[:id])
    authorize @user
    if @user.update_attributes(secure_params)
      redirect_to users_path, :notice => "User updated."
    else
      redirect_to users_path, :alert => "Unable to update user."
    end
  end

  def destroy
    user = User.find(params[:id])
    authorize user
    user.destroy
    redirect_to users_path, :notice => "User deleted."
  end

  private

  def secure_params
    params.require(:user).permit(:role)
  end

end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
rails_apps_pages-0.5.15 lib/generators/pages/authorized/templates/devise/users_controller.rb
rails_apps_pages-0.5.14 lib/generators/pages/authorized/templates/devise/users_controller.rb
rails_apps_pages-0.5.13 lib/generators/pages/authorized/templates/devise/users_controller.rb
rails_apps_pages-0.5.12 lib/generators/pages/authorized/templates/devise/users_controller.rb
rails_apps_pages-0.5.11 lib/generators/pages/authorized/templates/devise/users_controller.rb
rails_apps_pages-0.5.10 lib/generators/pages/authorized/templates/devise/users_controller.rb
rails_apps_pages-0.5.9 lib/generators/pages/authorized/templates/devise/users_controller.rb
rails_apps_pages-0.5.8 lib/generators/pages/authorized/templates/devise/users_controller.rb
rails_apps_pages-0.5.7 lib/generators/pages/authorized/templates/devise/users_controller.rb
rails_apps_pages-0.5.6 lib/generators/pages/authorized/templates/devise/users_controller.rb
rails_apps_pages-0.5.5 lib/generators/pages/authorized/templates/users_controller.rb
rails_apps_pages-0.5.4 lib/generators/pages/authorized/templates/users_controller.rb
rails_apps_pages-0.5.3 lib/generators/pages/authorized/templates/users_controller.rb
rails_apps_pages-0.5.2 lib/generators/pages/authorized/templates/users_controller.rb
rails_apps_pages-0.5.1 lib/generators/pages/authorized/templates/users_controller.rb