Sha256: 9ab7eda8711935bcdef5ad8055abc47f63653d83f854692f0b7ce2c08da7481e

Contents?: true

Size: 1.35 KB

Versions: 6

Compression:

Stored size: 1.35 KB

Contents

class ::IshManager::EmailCampaignsController < IshManager::ApplicationController

  def index
    authorize! :index, Ish::Campaign
    @campaigns = Ish::Campaign.where( :profile => @current_profile, :is_trash => false )
    if params[:is_done]
      @campaigns = @campaigns.where( :is_done => true )
    else
      @campaigns = @campaigns.where( :is_done => false )
    end
  end

  def new
    @new_campaign = Ish::Campaign.new
    authorize! :new, @new_campaign
  end

  def create
    @campaign = Ish::Campaign.new params[:campaign].permit!
    @campaign.profile = @current_profile
    authorize! :create, @campaign
    if @campaign.save
      flash[:notice] = "created campaign"
    else
      flash[:alert] = "Cannot create campaign: #{@campaign.errors.messages}"
    end
    redirect_to :action => 'index'
  end

  def show
    authorize! :redirect, IshManager::Ability
    redirect_to :action => :edit, :id => params[:id]
  end

  def edit
    @campaign = Ish::Campaign.find params[:id]
    authorize! :edit, @campaign
  end

  def update
    @campaign = Ish::Campaign.find params[:id]
    authorize! :update, @campaign
    if @campaign.update_attributes params[:campaign].permit!
      flash[:notice] = 'Successfully updated campaign.'
    else
      flash[:alert] = "Cannot update campaign: #{@campaign.errors.messages}"
    end
    redirect_to :action => 'index'
  end

end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
ish_manager-0.1.8.328 app/controllers/ish_manager/email_campaigns_controller.rb
ish_manager-0.1.8.327 app/controllers/ish_manager/email_campaigns_controller.rb
ish_manager-0.1.8.326 app/controllers/ish_manager/email_campaigns_controller.rb
ish_manager-0.1.8.325 app/controllers/ish_manager/email_campaigns_controller.rb
ish_manager-0.1.8.324 app/controllers/ish_manager/email_campaigns_controller.rb
ish_manager-0.1.8.323 app/controllers/ish_manager/email_campaigns_controller.rb