Sha256: d55399472aad8fbd877eb9da1cdc9a8b81cc5e6b9f996b7f97dab048515a9c2a

Contents?: true

Size: 1.11 KB

Versions: 5

Compression:

Stored size: 1.11 KB

Contents

require_dependency "chaskiq/application_controller"

module Chaskiq
  class Manage::AttachmentsController < ApplicationController

    before_filter :authentication_method
    before_filter :find_campaign

    def index
      @attachments = @campaign.attachments.page(params[:page]).per(50)
      respond_to do |format|
        format.html
        format.json { render json: @attachments }
      end
    end

    def show
      @attachment = @campaign.attachments.find(params[:id])
    end

    def new
      @attachment = @campaign.attachments.new
    end

    def create
      @attachment = @campaign.attachments.create(resource_params)
      respond_to do |format|
        format.html
        format.json { render json: @attachment }
      end
    end

  protected

    def find_campaign
      @campaign = Chaskiq::Campaign.find(params[:campaign_id])
    end

    def resource_params
      return [] if request.get?
      params[:attachment] = {} unless params[:attachment].present?
      params[:attachment][:image] = params[:image] if params[:image].present?
      params.require(:attachment).permit! #(:name)
    end

  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
chaskiq-0.0.6 app/controllers/chaskiq/manage/attachments_controller.rb
chaskiq-0.0.5 app/controllers/chaskiq/manage/attachments_controller.rb
chaskiq-0.0.4 app/controllers/chaskiq/manage/attachments_controller.rb
chaskiq-0.0.3 app/controllers/chaskiq/manage/attachments_controller.rb
chaskiq-0.0.2 app/controllers/chaskiq/manage/attachments_controller.rb