Sha256: 7f186a1a6ae03876ec720bd667136ed15650d8f09c26e3414466e84abca4a952

Contents?: true

Size: 1.09 KB

Versions: 7

Compression:

Stored size: 1.09 KB

Contents

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

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

  def create
    @signup = Signup.new(params[:signup])
    @signup.user = current_user
    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

  private

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

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
saucy-0.1.18 app/controllers/accounts_controller.rb
saucy-0.1.17 app/controllers/accounts_controller.rb
saucy-0.1.16 app/controllers/accounts_controller.rb
saucy-0.1.15 app/controllers/accounts_controller.rb
saucy-0.1.14 app/controllers/accounts_controller.rb
saucy-0.1.13 app/controllers/accounts_controller.rb
saucy-0.1.12 app/controllers/accounts_controller.rb