Sha256: 1ae396d45ed3cbcce64a2776e86d70a0147d50187a8677cb02e40599dedbd53d

Contents?: true

Size: 1.26 KB

Versions: 5

Compression:

Stored size: 1.26 KB

Contents

class ::IshManager::LeadsController < IshManager::ApplicationController

  ## alphabetized : )

  def create
    @lead = Ish::Lead.new params[:lead].permit!
    @lead.profile = current_user.profile
    authorize! :create, @lead
    if @lead.save
      flash[:notice] = "created lead"
    else
      flash[:alert] = "Cannot create lead: #{@lead.errors.messages}"
    end
    redirect_to :action => 'index'
  end

  def edit
    @lead = Ish::Lead.find params[:id]
    authorize! :edit, @lead
  end

  def index
    authorize! :index, Ish::Lead
    @leads = Ish::Lead.all # where( :profile => current_user.profile, :is_trash => false )
    if params[:is_done]
      @leads = @leads.where( :is_done => true )
    else
      @leads = @leads.where( :is_done => false )
    end
  end

  def new
    @new_lead = Ish::Lead.new
    authorize! :new, @new_lead
  end

  def show
    authorize! :redirect, IshManager::Ability
    redirect_to :action => :edit, :id => params[:id]
  end

  def update
    @lead = Ish::Lead.find params[:id]
    authorize! :update, @lead
    if @lead.update_attributes params[:lead].permit!
      flash[:notice] = 'Successfully updated lead.'
    else
      flash[:alert] = "Cannot update lead: #{@lead.errors.messages}"
    end
    redirect_to :action => 'index'
  end

end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
ish_manager-0.1.8.322 app/controllers/ish_manager/leads_controller.rb
ish_manager-0.1.8.321 app/controllers/ish_manager/leads_controller.rb
ish_manager-0.1.8.320 app/controllers/ish_manager/leads_controller.rb
ish_manager-0.1.8.318 app/controllers/ish_manager/leads_controller.rb
ish_manager-0.1.8.317 app/controllers/ish_manager/leads_controller.rb