Class: UsersController

Inherits:
Spree::BaseController
  • Object
show all
Defined in:
app/controllers/users_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'app/controllers/users_controller.rb', line 9

def create
  @user = User.new(params[:user])
  if @user.save

    if current_order
      current_order.associate_user!(@user)
      session[:guest_token] = nil
    end

    redirect_back_or_default(root_url)
  else
    render 'new'
  end

end

#showObject



5
6
7
# File 'app/controllers/users_controller.rb', line 5

def show
  @orders = @user.orders.complete
end

#updateObject



25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'app/controllers/users_controller.rb', line 25

def update
  if @user.update_attributes(params[:user])
    if params[:user][:password].present?
      # this logic needed b/c devise wants to log us out after password changes
      user = User.reset_password_by_token(params[:user])
      (@user, :event => :authentication, :bypass => !Spree::Auth::Config[:signout_after_password_change])
    end
    flash.notice = I18n.t("account_updated")
    redirect_to 
  else
    render 'edit'
  end

end