Class: UsersController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- UsersController
- Defined in:
- app/controllers/users_controller.rb
Instance Method Summary collapse
- #append ⇒ Object
- #create ⇒ Object
- #destroy ⇒ Object
- #edit ⇒ Object
- #finduser ⇒ Object
- #index ⇒ Object
- #lip ⇒ Object
- #new ⇒ Object
- #search ⇒ Object
- #show ⇒ Object
- #update ⇒ Object
Instance Method Details
#append ⇒ Object
21 22 |
# File 'app/controllers/users_controller.rb', line 21 def append end |
#create ⇒ Object
23 24 25 26 27 28 29 30 31 32 |
# File 'app/controllers/users_controller.rb', line 23 def create @user=User.new(params[:user]) @user.last_lip=lip #redirect_to @user.save ? users_path : new_user_path if @user.save redirect_to users_path else redirect_to new_user_path end end |
#destroy ⇒ Object
54 55 56 57 58 59 60 61 |
# File 'app/controllers/users_controller.rb', line 54 def destroy begin @user.destroy rescue flash[:error]="删除失败!" end redirect_to users_path end |
#edit ⇒ Object
33 34 |
# File 'app/controllers/users_controller.rb', line 33 def edit end |
#finduser ⇒ Object
9 10 11 |
# File 'app/controllers/users_controller.rb', line 9 def finduser @user=User.find(params[:id]) end |
#index ⇒ Object
13 14 15 16 17 |
# File 'app/controllers/users_controller.rb', line 13 def index @page,@per_page=params[:page],5 @minum = @page ? @per_page*(@page.to_i-1) : 0 @users=User.paginate :page=>@page,:per_page=>@per_page,:order=>"created_at DESC" end |
#lip ⇒ Object
6 7 8 |
# File 'app/controllers/users_controller.rb', line 6 def lip request.remote_ip end |
#new ⇒ Object
18 19 20 |
# File 'app/controllers/users_controller.rb', line 18 def new @user=User.new end |
#search ⇒ Object
36 37 38 39 40 41 42 43 |
# File 'app/controllers/users_controller.rb', line 36 def search redirect_to users_path and return if params[:str].blank? str=params[:str].strip @users = ["!",">","<"].include?(str[0]) ? User.search_ltime(str) : User.search(str) @page,@per_page=params[:page],5 @minum = @page ? @per_page*(@page.to_i-1) : 0 @users=@users.paginate :page=>@page,:per_page=>@per_page,:order=>"created_at DESC" end |
#show ⇒ Object
52 53 |
# File 'app/controllers/users_controller.rb', line 52 def show end |
#update ⇒ Object
45 46 47 48 49 50 51 |
# File 'app/controllers/users_controller.rb', line 45 def update params[:user][:last_ip]=lip lpassword=params[:user][:lpassword] params[:user][:lpassword] = lpassword.blank? ? @user.lpassword : User.encrypt(lpassword) @user.update_attributes(params[:user]) redirect_to users_path end |