Sha256: 644be851a675411a879b7e868ecd9e95b56f83a0381389be7bd7bac440c2fd0d

Contents?: true

Size: 1.4 KB

Versions: 31

Compression:

Stored size: 1.4 KB

Contents

class AccountsController < ApplicationController
  before_filter :authenticate, :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
  end

  def create
    @plan = Plan.find(params[:plan_id])
    @signup = Signup.new(params[:signup])
    @signup.user = current_user
    @signup.plan = @plan
    if @signup.save
      flash[:success] = "Account was created."
      sign_in @signup.user
      redirect_to root_url
    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

31 entries across 31 versions & 1 rubygems

Version Path
saucy-0.2.28.1 app/controllers/accounts_controller.rb
saucy-0.2.42 app/controllers/accounts_controller.rb
saucy-0.2.41 app/controllers/accounts_controller.rb
saucy-0.2.40 app/controllers/accounts_controller.rb
saucy-0.2.39 app/controllers/accounts_controller.rb
saucy-0.2.38 app/controllers/accounts_controller.rb
saucy-0.2.36 app/controllers/accounts_controller.rb
saucy-0.2.35 app/controllers/accounts_controller.rb
saucy-0.2.34 app/controllers/accounts_controller.rb
saucy-0.2.33 app/controllers/accounts_controller.rb
saucy-0.2.32 app/controllers/accounts_controller.rb
saucy-0.2.31 app/controllers/accounts_controller.rb
saucy-0.2.30 app/controllers/accounts_controller.rb
saucy-0.2.29 app/controllers/accounts_controller.rb
saucy-0.2.28 app/controllers/accounts_controller.rb
saucy-0.2.27 app/controllers/accounts_controller.rb
saucy-0.2.26 app/controllers/accounts_controller.rb
saucy-0.2.25 app/controllers/accounts_controller.rb
saucy-0.2.24 app/controllers/accounts_controller.rb
saucy-0.2.21 app/controllers/accounts_controller.rb