Module: Ixtlan::Controllers::UsersController
- Includes:
- SearchQuery
- Defined in:
- lib/ixtlan/controllers/users_controller.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#create ⇒ Object
POST /users POST /users.xml.
-
#destroy ⇒ Object
DELETE /users/1 DELETE /users/1.xml.
-
#edit ⇒ Object
GET /users/1/edit.
-
#index ⇒ Object
GET /users GET /users.xml.
-
#new ⇒ Object
GET /users/new GET /users/new.xml.
-
#show ⇒ Object
GET /users/1 GET /users/1.xml.
-
#update ⇒ Object
PUT /users/1 PUT /users/1.xml.
Class Method Details
.included(base) ⇒ Object
8 9 10 |
# File 'lib/ixtlan/controllers/users_controller.rb', line 8 def self.included(base) base.cache_headers :protected, false # no_store == false end |
Instance Method Details
#create ⇒ Object
POST /users POST /users.xml
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/ixtlan/controllers/users_controller.rb', line 66 def create user_params = params[:user] groups = adjust_params_and_return_groups(user_params) @user = USER.new(user_params) @user.current_user = current_user @user.reset_password @user.update_all_children(groups) respond_to do |format| if @user.save flash[:notice] = "User was successfully created: #{@user.password}" format.html { redirect_to(user_url(@user.id)) } format.xml { render :xml => @user, :status => :created, :location => user_url(@user.id) + ".xml" } if Configuration.instance.password_sender_email ::Ixtlan::Mailer.deliver_new_user(@user.email, Configuration.instance.password_sender_email, @user.login, Configuration.instance.login_url) ::Ixtlan::Mailer.deliver_password(@user.email, Configuration.instance.password_sender_email, @user.password) end else format.html { render :action => "new" } format.xml { render :xml => @user.errors, :status => :unprocessable_entity } end end end |
#destroy ⇒ Object
DELETE /users/1 DELETE /users/1.xml
114 115 116 117 118 119 120 121 122 123 124 |
# File 'lib/ixtlan/controllers/users_controller.rb', line 114 def destroy @user = USER.first_or_get(params[:id]) # @user.current_user = current_user @user.destroy if @user respond_to do |format| flash[:notice] = 'User was successfully deleted.' format.html { redirect_to(users_url) } format.xml { head :ok } end end |
#edit ⇒ Object
GET /users/1/edit
60 61 62 |
# File 'lib/ixtlan/controllers/users_controller.rb', line 60 def edit @user = USER.first_or_get!(params[:id]) end |
#index ⇒ Object
GET /users GET /users.xml
28 29 30 31 32 33 34 35 |
# File 'lib/ixtlan/controllers/users_controller.rb', line 28 def index @users = query(USER, :login, :email) respond_to do |format| format.html format.xml { render :xml => @users } end end |
#new ⇒ Object
GET /users/new GET /users/new.xml
50 51 52 53 54 55 56 57 |
# File 'lib/ixtlan/controllers/users_controller.rb', line 50 def new @user = USER.new respond_to do |format| format.html # new.html.erb format.xml { render :xml => @user } end end |
#show ⇒ Object
GET /users/1 GET /users/1.xml
39 40 41 42 43 44 45 46 |
# File 'lib/ixtlan/controllers/users_controller.rb', line 39 def show @user = USER.first_or_get!(params[:id]) respond_to do |format| format.html # show.html.erb format.xml { render :xml => @user } end end |
#update ⇒ Object
PUT /users/1 PUT /users/1.xml
93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 |
# File 'lib/ixtlan/controllers/users_controller.rb', line 93 def update @user = USER.first_or_get!(params[:id]) @user.current_user = current_user user_params = params[:user] @user.update_all_children(adjust_params_and_return_groups(user_params)) @user.attributes = user_params respond_to do |format| if @user.save() or not @user.dirty? flash[:notice] = 'User was successfully updated.' format.html { redirect_to(user_url(@user.id)) } format.xml { render :xml => @user } else format.html { render :action => "edit" } format.xml { render :xml => @user.errors, :status => :unprocessable_entity } end end end |