Sha256: 79329ba0f13f76fe9063f9f210544a0ec22cc97d8a0d14c02f52a53ef5673188

Contents?: true

Size: 678 Bytes

Versions: 1

Compression:

Stored size: 678 Bytes

Contents

class FamilyGallery::MultiplePicturesController < FamilyGallery::BaseController
  before_filter :set_group_and_auth

  def new
  end

  def create
    picture_params[:files].each do |file|
      picture = FamilyGallery::Picture.new(
        image: file,
        user_owner: current_user,
        user_uploaded: current_user
      )
      picture.groups << @group
      picture.save!
    end

    redirect_to @group
  end

private

  def set_group_and_auth
    @group = FamilyGallery::Group.find(params[:group_id])
    authorize! :create, FamilyGallery::Picture.new(groups: [@group])
  end

  def picture_params
    params.require(:multiple_pictures).permit(files: [])
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
family_gallery-0.0.8 app/controllers/family_gallery/multiple_pictures_controller.rb