Class: IshManager::LeadsetsController

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

Instance Method Summary collapse

Methods inherited from ApplicationController

#home

Instance Method Details

#createObject

alphabetized : )



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

def create
  @leadset = Leadset.new params[:leadset].permit!
  @leadset.profile = @current_profile
  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

#editObject



18
19
20
21
# File 'app/controllers/ish_manager/leadsets_controller.rb', line 18

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

#indexObject



23
24
25
26
27
28
29
30
31
# File 'app/controllers/ish_manager/leadsets_controller.rb', line 23

def index
  authorize! :index, Leadset
  @leadsets = Leadset.all # where( :profile => @current_profile, :is_trash => false )
  # if params[:is_done]
  #   @leadsets = @leadsets.where( :is_done => true )
  # else
  #   @leadsets = @leadsets.where( :is_done => false )
  # end
end

#newObject



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

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

#showObject



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

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

#updateObject



43
44
45
46
47
48
49
50
51
52
# File 'app/controllers/ish_manager/leadsets_controller.rb', line 43

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