Sha256: 2f37b653821adc21ff4d63e3a08072d81143d56c877b55e283a5f54c8e761af1

Contents?: true

Size: 1.35 KB

Versions: 152

Compression:

Stored size: 1.35 KB

Contents

class IshManager::CampaignsController < IshManager::ApplicationController

  def index
    authorize! :index, Ish::Campaign
    @campaigns = Ish::Campaign.where( :profile => current_user.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_user.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

152 entries across 152 versions & 1 rubygems

Version Path
ish_manager-0.1.8.316 app/controllers/ish_manager/campaigns_controller.rb
ish_manager-0.1.8.315 app/controllers/ish_manager/campaigns_controller.rb
ish_manager-0.1.8.314 app/controllers/ish_manager/campaigns_controller.rb
ish_manager-0.1.8.313 app/controllers/ish_manager/campaigns_controller.rb
ish_manager-0.1.8.312 app/controllers/ish_manager/campaigns_controller.rb
ish_manager-0.1.8.311 app/controllers/ish_manager/campaigns_controller.rb
ish_manager-0.1.8.310 app/controllers/ish_manager/campaigns_controller.rb
ish_manager-0.1.8.309 app/controllers/ish_manager/campaigns_controller.rb
ish_manager-0.1.8.308 app/controllers/ish_manager/campaigns_controller.rb
ish_manager-0.1.8.307 app/controllers/ish_manager/campaigns_controller.rb
ish_manager-0.1.8.306 app/controllers/ish_manager/campaigns_controller.rb
ish_manager-0.1.8.305 app/controllers/ish_manager/campaigns_controller.rb
ish_manager-0.1.8.304 app/controllers/ish_manager/campaigns_controller.rb
ish_manager-0.1.8.303 app/controllers/ish_manager/campaigns_controller.rb
ish_manager-0.1.8.302 app/controllers/ish_manager/campaigns_controller.rb
ish_manager-0.1.8.301 app/controllers/ish_manager/campaigns_controller.rb
ish_manager-0.1.8.300 app/controllers/ish_manager/campaigns_controller.rb
ish_manager-0.1.8.299 app/controllers/ish_manager/campaigns_controller.rb
ish_manager-0.1.8.298 app/controllers/ish_manager/campaigns_controller.rb
ish_manager-0.1.8.296 app/controllers/ish_manager/campaigns_controller.rb