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.295 app/controllers/ish_manager/campaigns_controller.rb
ish_manager-0.1.8.294 app/controllers/ish_manager/campaigns_controller.rb
ish_manager-0.1.8.293 app/controllers/ish_manager/campaigns_controller.rb
ish_manager-0.1.8.292 app/controllers/ish_manager/campaigns_controller.rb
ish_manager-0.1.8.291 app/controllers/ish_manager/campaigns_controller.rb
ish_manager-0.1.8.290 app/controllers/ish_manager/campaigns_controller.rb
ish_manager-0.1.8.289 app/controllers/ish_manager/campaigns_controller.rb
ish_manager-0.1.8.288 app/controllers/ish_manager/campaigns_controller.rb
ish_manager-0.1.8.287 app/controllers/ish_manager/campaigns_controller.rb
ish_manager-0.1.8.284 app/controllers/ish_manager/campaigns_controller.rb
ish_manager-0.1.8.282 app/controllers/ish_manager/campaigns_controller.rb
ish_manager-0.1.8.281 app/controllers/ish_manager/campaigns_controller.rb
ish_manager-0.1.8.280 app/controllers/ish_manager/campaigns_controller.rb
ish_manager-0.1.8.279 app/controllers/ish_manager/campaigns_controller.rb
ish_manager-0.1.8.278 app/controllers/ish_manager/campaigns_controller.rb
ish_manager-0.1.8.277 app/controllers/ish_manager/campaigns_controller.rb
ish_manager-0.1.8.274 app/controllers/ish_manager/campaigns_controller.rb
ish_manager-0.1.8.273 app/controllers/ish_manager/campaigns_controller.rb
ish_manager-0.1.8.272 app/controllers/ish_manager/campaigns_controller.rb
ish_manager-0.1.8.271 app/controllers/ish_manager/campaigns_controller.rb