Class: AccountsController

Inherits:
ApplicationController
  • Object
show all
Includes:
Saucy::Coupons
Defined in:
app/controllers/accounts_controller.rb

Instance Method Summary collapse

Methods included from Saucy::Coupons

#set_coupon_cookie

Instance Method Details

#createObject



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'app/controllers/accounts_controller.rb', line 16

def create
  @plan   = Plan.find(params[:plan_id])
  @signup = Signup.new(params[:signup])

  @signup.coupon = Coupon.find_by_name(session[:coupon_name])
  @signup.user   = current_user
  @signup.plan   = @plan

  if @signup.save
    Saucy::Notifications.notify_observers("account_created", :request => request,
                                                             :account => @signup.)
     @signup.user
    redirect_to (@signup.)
  else
    render :action => 'new'
  end
end

#destroyObject



58
59
60
61
62
63
64
# File 'app/controllers/accounts_controller.rb', line 58

def destroy
  Saucy::Notifications.notify_observers("canceled", :request => request,
                                                    :account => )
  .destroy
  flash[:success] = "Your account has been deleted."
  redirect_to root_url
end

#editObject



44
45
46
# File 'app/controllers/accounts_controller.rb', line 44

def edit
  @account = 
end

#indexObject



34
35
36
37
38
39
40
41
42
# File 'app/controllers/accounts_controller.rb', line 34

def index
  if current_user.projects.size == 1
    flash.keep
    project = current_user.projects.first
    redirect_to (project., project)
  else
    @accounts = current_user.accounts
  end
end

#newObject



9
10
11
12
13
14
# File 'app/controllers/accounts_controller.rb', line 9

def new
  @plan = Plan.find(params[:plan_id])
  @signup = Signup.new
  Saucy::Notifications.notify_observers("plan_viewed", :request => request,
                                                       :plan    => @plan)
end

#updateObject



48
49
50
51
52
53
54
55
56
# File 'app/controllers/accounts_controller.rb', line 48

def update
  @account = 
  if @account.update_attributes(params[:account])
    flash[:success] = 'Account was updated.'
    redirect_to edit_profile_url
  else
    render :action => :edit
  end
end