Sha256: babf07a86a04c2c7e2615c2837f0f30f3f7ed52b189d15aeccc5da090f52e632

Contents?: true

Size: 1.71 KB

Versions: 13

Compression:

Stored size: 1.71 KB

Contents

class AccountsController < ApplicationController
  before_filter :authorize, :only => [:index, :edit, :update]
  before_filter :authorize_admin, :except => [:new, :create, :index]
  before_filter :ensure_active_account, :only => [:edit, :update]
  layout Saucy::Layouts.to_proc

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

  def create
    @plan = Plan.find(params[:plan_id])
    @signup = Signup.new(params[:signup])
    @signup.user = current_user
    @signup.plan = @plan
    if @signup.save
      Saucy::Configuration.notify("account_created", :request => request,
                                                     :account => @signup.account)
      flash[:success] = "Account was created."
      sign_in @signup.user
      redirect_to new_account_project_path(@signup.account)
    else
      render :action => 'new'
    end
  end

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

  def edit
    @account = current_account
  end

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

  def destroy
    current_account.destroy
    flash[:success] = "Your account has been deleted."
    redirect_to root_url
  end

  private

  def current_account
    Account.find_by_keyword!(params[:id])
  end

  def current_account?
    params[:id].present?
  end
end

Version data entries

13 entries across 13 versions & 2 rubygems

Version Path
saasy-0.0.2.alpha3 app/controllers/accounts_controller.rb
saasy-0.0.2.alpha2 app/controllers/accounts_controller.rb
saasy-0.0.2.alpha1 app/controllers/accounts_controller.rb
saasy-0.0.1 app/controllers/accounts_controller.rb
saucy-0.8.2 app/controllers/accounts_controller.rb
saucy-0.8.1 app/controllers/accounts_controller.rb
saucy-0.8.0 app/controllers/accounts_controller.rb
saucy-0.7.3 app/controllers/accounts_controller.rb
saucy-0.7.2 app/controllers/accounts_controller.rb
saucy-0.7.1 app/controllers/accounts_controller.rb
saucy-0.7.0 app/controllers/accounts_controller.rb
saucy-0.6.1 app/controllers/accounts_controller.rb
saucy-0.6.0 app/controllers/accounts_controller.rb