Sha256: 0522b4c771fd36a77292d8eb1db736d49e1263d20b28dc5258e55cd54e5923e8
Contents?: true
Size: 1.27 KB
Versions: 1
Compression:
Stored size: 1.27 KB
Contents
class E9Crm::CampaignsController < E9Crm::ResourcesController defaults :resource_class => Campaign include E9Rails::Controllers::Orderable before_filter :redirect_new_to_subclass, :only => :new self.should_paginate_index = false has_scope :of_group, :as => :group, :only => :index has_scope :active, :only => :index, :default => 'true' do |_, scope, value| scope.active(E9.true_value?(value)) end has_scope :of_type, :as => :type, :only => :index do |_, scope, value| scope.of_type("#{type}_campaign".classify) end protected def redirect_new_to_subclass types = %w(advertising affiliate email sales) type = types.member?(params[:type]) ? params[:type] : types.first redirect_to send("new_#{type}_campaign_path") end def collection_scope #end_of_association_chain.typed.includes(:campaign_group) # NOTE this is a pretty ugly join just to be able to sort on campaign group name end_of_association_chain.typed .joins("left outer join campaign_groups on campaign_groups.id = campaigns.campaign_group_id") .select("campaigns.*, campaign_groups.name campaign_group_name") end def default_ordered_on 'type,campaign_group_name,name' end def default_ordered_dir 'ASC' end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
e9_crm-0.1.20 | app/controllers/e9_crm/campaigns_controller.rb |