Sha256: 8de816d8ba46f37159090bc4ba604f5bd5357f20b4f86e77b7cab1f6ffef7ff4

Contents?: true

Size: 1.34 KB

Versions: 6

Compression:

Stored size: 1.34 KB

Contents

class AccountsController < ApplicationController
  skip_before_filter :authenticate, :only => [:new, :create]
  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
      if @signup.email_confirmed?
        flash[:success] = "Account was created."
        sign_in @signup.user
        redirect_to root_url
      else
        flash[:success] = "Account was created. Instructions for confirming your " +
                          "account have been sent to the email address you provided."
        redirect_to sign_in_url
      end
    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_url!(params[:id])
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
saucy-0.1.6 app/controllers/accounts_controller.rb
saucy-0.1.5 app/controllers/accounts_controller.rb
saucy-0.1.4 app/controllers/accounts_controller.rb
saucy-0.1.3 app/controllers/accounts_controller.rb
saucy-0.1.2 app/controllers/accounts_controller.rb
saucy-0.1.1 app/controllers/accounts_controller.rb