Class: Muck::ActivationsController

Inherits:
ApplicationController
  • Object
show all
Defined in:
app/controllers/muck/activations_controller.rb

Instance Method Summary collapse

Instance Method Details

#newObject



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'app/controllers/muck/activations_controller.rb', line 6

def new
  @user = User.find_using_perishable_token(params[:id])
  if @user.blank?
    flash[:notice] = t('muck.users.activation_not_found')
    redirect_to new_user_path and return
  end
  
  if @user.active?
    flash[:notice] = t('muck.users.already_activated')
    redirect_to  and return
  end
  
  if @user.activate!
    UserSession.create(@user)
    flash[:notice] = t('muck.users.account_activated')
    @user.deliver_activation_confirmation!
    redirect_to welcome_user_path(@user)
  else
    render :action => :new
  end
  
end