Class: IshManager::LeadsetsController
Instance Method Summary
collapse
#basic_auth, #home, #tinymce
Instance Method Details
#create ⇒ Object
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
|
#destroy ⇒ Object
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
|
#edit ⇒ Object
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
|
#index ⇒ Object
34
35
36
37
38
39
40
41
|
# File 'app/controllers/ish_manager/leadsets_controller.rb', line 34
def index
authorize! :index, Leadset
@leadsets = Leadset.all.kept.includes(:leads)
if params[:q].present?
@leadsets = @leadsets.where(" company_url LIKE ? ", "%#{params[:q]}%" )
end
@leadsets = @leadsets.page( params[:leadsets_page] ).per( current_profile.per_page )
end
|
#new ⇒ Object
43
44
45
46
|
# File 'app/controllers/ish_manager/leadsets_controller.rb', line 43
def new
@new_leadset = Leadset.new
authorize! :new, @new_leadset
end
|
#show ⇒ Object
48
49
50
51
52
53
54
55
|
# File 'app/controllers/ish_manager/leadsets_controller.rb', line 48
def show
@leadset = Leadset.find params[:id]
authorize! :show, @leadset
@email_contexts = {}
@leadset.employees.each do |lead|
@email_contexts[lead.email] = lead.email_contexts
end
end
|
#update ⇒ Object
57
58
59
60
61
62
63
64
65
66
|
# File 'app/controllers/ish_manager/leadsets_controller.rb', line 57
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
|