Sha256: f9db2b94ddebaabe223462cb4f43e5b347d62c6492222f53ee926f24b4ae1d77

Contents?: true

Size: 1016 Bytes

Versions: 1

Compression:

Stored size: 1016 Bytes

Contents

class FamilyGallery::PicturesController < FamilyGallery::ResourcesController
  before_filter :set_group

  def show
    if view_context.agent_mobile?
      @width = 400
      @picture_url = view_context.rails_imager_p(@picture.image, maxwidth: 800)
    else
      @width = 800
      @picture_url = view_context.rails_imager_p(@picture.image, maxwidth: 1600)
    end

    @height = @picture.height_for_width(@width)

    if @group
      @previous_picture = @picture.previous_picture_in_group(@group)
      @next_picture = @picture.next_picture_in_group(@group)
    end
  end

private

  def set_group
    @group = FamilyGallery::Group.find(params[:group_id]) if params[:group_id]
  end

  def after_assign
    resource_instance.user_uploaded = current_user
    resource_instance.user_owner = current_user
    resource_instance.groups << FamilyGallery::Group.find(params[:group_id]) if params[:group_id].present?
  end

  def resource_params
    params.require(:picture).permit(:title, :description, :image)
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

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