Sha256: 785b228faaa3afb423ab94bb53e145774a1d63f065b0eb5cc7116f7e99556ffa
Contents?: true
Size: 1.67 KB
Versions: 5
Compression:
Stored size: 1.67 KB
Contents
class Admin::UsersController < Admin::ApplicationController belongs_to_spud_app :users add_breadcrumb "Users", :admin_users_path before_action :load_user, :only => [:edit, :update, :show, :destroy] respond_to :html def index @spud_users = SpudUser.ordered.paginate(:page => params[:page], :per_page => 15) if params[:search] @spud_users = @spud_users.where_name_like(params[:search]) end respond_with @spud_users end def show respond_with @user end def new @user = SpudUser.new respond_with @user end def create @user = SpudUser.new(user_params) if @user.save render 'show', :status => 200 else render 'new', :status => 422 end end def edit respond_with @user end def update @user.update_attributes(user_params) respond_with @user, :location => admin_user_path(@user), :status => 200 end def destroy @user.destroy respond_with @user, :location => admin_users_path end private def load_user @user = SpudUser.where(:id => params[:id]).first if @user.blank? flash[:error] = "User not found!" redirect_to admin_users_path and return false end return true end # attr_accessible :login,:email,:first_name,:last_name,:password,:password_confirmation,:password_salt,:last_login_at,:last_request_at,:last_login_ip,:failed_login_count,:current_login_at,:login_count,:persistence_token,:perishable_token,:single_access_token,:crypted_password, :current_login_ip, :created_at, :updated_at,:time_zone, :as => [:default, :admin] # attr_accessible :super_admin, :spud_role_id, :id, :as => :admin def user_params params.require(:spud_user).permit! end end
Version data entries
5 entries across 5 versions & 1 rubygems