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 31 32 33 34 |
# File 'app/controllers/wco/leadsets_controller.rb', line 22 def destroy :create, Wco::Leadset leadsets = Wco::Leadset.find( params[:leadset_ids] ) rescue [] @results = [] leadsets.each do |leadset| @results.push leadset.destroy end if params[:id] @results.push Wco::Leadset.find(params[:id]).destroy end flash[:notice] = "destroy outcome: #{@results.inspect}." redirect_to request.referrer || { action: 'index' } end |
#edit ⇒ Object
36 37 38 39 |
# File 'app/controllers/wco/leadsets_controller.rb', line 36 def edit @leadset = Leadset.find params[:id] :edit, @leadset end |
#index ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 |
# File 'app/controllers/wco/leadsets_controller.rb', line 41 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
53 54 55 56 |
# File 'app/controllers/wco/leadsets_controller.rb', line 53 def new @new_leadset = Leadset.new :new, @new_leadset end |
#show ⇒ Object
58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'app/controllers/wco/leadsets_controller.rb', line 58 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
73 74 75 76 77 78 79 80 81 82 83 |
# File 'app/controllers/wco/leadsets_controller.rb', line 73 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 |