Class: IshManager::LeadsetsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/ish_manager/leadsets_controller.rb

Instance Method Summary collapse

Methods inherited from ApplicationController

#basic_auth, #home

Instance Method Details

#createObject

alphabetized : )



8
9
10
11
12
13
14
15
16
17
# File 'app/controllers/ish_manager/leadsets_controller.rb', line 8

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

#destroyObject



19
20
21
22
23
24
25
26
27
# File 'app/controllers/ish_manager/leadsets_controller.rb', line 19

def destroy
  leadsets = Leadset.find( params[:leadset_ids] )
  @results = []
  leadsets.each do |leadset|
    @results.push leadset.discard
  end
  flash[:notice] = "Discard outcome: #{@results.inspect}."
  redirect_to action: 'index'
end

#editObject



29
30
31
32
# File 'app/controllers/ish_manager/leadsets_controller.rb', line 29

def edit
  @leadset = Leadset.find params[:id]
  authorize! :edit, @leadset
end

#indexObject



34
35
36
37
# File 'app/controllers/ish_manager/leadsets_controller.rb', line 34

def index
  authorize! :index, Leadset
  @leadsets = Leadset.all.kept # where( :profile => @current_profile, :is_trash => false )
end

#newObject



39
40
41
42
# File 'app/controllers/ish_manager/leadsets_controller.rb', line 39

def new
  @new_leadset = Leadset.new
  authorize! :new, @new_leadset
end

#showObject



44
45
46
47
# File 'app/controllers/ish_manager/leadsets_controller.rb', line 44

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

#updateObject



49
50
51
52
53
54
55
56
57
58
# File 'app/controllers/ish_manager/leadsets_controller.rb', line 49

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