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
42
43
44
|
# 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]}%" )
if @leadsets.length == 1
return redirect_to action: :show, id: @leadsets[0][:id]
end
end
@leadsets = @leadsets.page( params[:leadsets_page] ).per( current_profile.per_page )
end
|
#new ⇒ Object
46
47
48
49
|
# File 'app/controllers/ish_manager/leadsets_controller.rb', line 46
def new
@new_leadset = Leadset.new
authorize! :new, @new_leadset
end
|
#show ⇒ Object
51
52
53
54
55
56
57
58
59
60
61
62
63
|
# File 'app/controllers/ish_manager/leadsets_controller.rb', line 51
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
@employees = @leadset.employees.page( params[:leads_page] ).per( current_profile.per_page )
@subscriptions = @leadset.subscriptions
@invoices = @leadset.invoices
end
|
#update ⇒ Object
65
66
67
68
69
70
71
72
73
74
|
# File 'app/controllers/ish_manager/leadsets_controller.rb', line 65
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 => 'show', id: @leadset.id
end
|