Class: Wco::LeadsetsController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- Wco::LeadsetsController
- Defined in:
- app/controllers/wco/leadsets_controller.rb
Instance Method Summary collapse
-
#create ⇒ Object
alphabetized : ).
- #destroy ⇒ Object
- #edit ⇒ Object
- #index ⇒ Object
- #new ⇒ Object
- #show ⇒ Object
- #update ⇒ Object
Instance Method Details
#create ⇒ Object
alphabetized : )
10 11 12 13 14 15 16 17 18 19 20 |
# File 'app/controllers/wco/leadsets_controller.rb', line 10 def create params[:leadset][:serverhost_ids].delete '' @leadset = Leadset.new params[:leadset].permit! :create, @leadset if @leadset.save flash[:notice] = "created leadset" else flash[:alert] = "Cannot create leadset: #{@leadset.errors.}" end redirect_to :action => 'index' end |
#destroy ⇒ Object
22 23 24 25 26 27 28 29 30 |
# File 'app/controllers/wco/leadsets_controller.rb', line 22 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
32 33 34 35 |
# File 'app/controllers/wco/leadsets_controller.rb', line 32 def edit @leadset = Leadset.find params[:id] :edit, @leadset end |
#index ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 |
# File 'app/controllers/wco/leadsets_controller.rb', line 37 def index :index, Leadset @leadsets = Leadset.all.includes(:leads) if params[:q].present? @leadsets = @leadsets.where({ company_url: /.*#{params[:q]}.*/i }) 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
49 50 51 52 |
# File 'app/controllers/wco/leadsets_controller.rb', line 49 def new @new_leadset = Leadset.new :new, @new_leadset end |
#show ⇒ Object
54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'app/controllers/wco/leadsets_controller.rb', line 54 def show @leadset = Leadset.find params[:id] :show, @leadset @email_contexts = {} @leadset.leads.each do |lead| @email_contexts[lead.email] = lead.email_contexts end @leads = @leadset.leads.page( params[:leads_page] ).per( current_profile.per_page ) @logs = @leadset.logs.page( params[:logs_page] ).per( current_profile.per_page ) @subscriptions = @leadset.subscriptions @invoices = @leadset.invoices end |
#update ⇒ Object
69 70 71 72 73 74 75 76 77 78 79 |
# File 'app/controllers/wco/leadsets_controller.rb', line 69 def update params[:leadset][:serverhost_ids].present? && params[:leadset][:serverhost_ids].delete('') @leadset = Leadset.find params[:id] :update, @leadset if @leadset.update_attributes params[:leadset].permit! flash[:notice] = 'Successfully updated leadset.' else flash[:alert] = "Cannot update leadset: #{@leadset.errors.}" end redirect_to :action => 'show', id: @leadset.id end |