Sha256: d003391732d4f8c8b73c94100981e0e224e331dc7f3d4c0a3befe7849889b8cf

Contents?: true

Size: 671 Bytes

Versions: 16

Compression:

Stored size: 671 Bytes

Contents

module AdminPictureController
  include Gaku::ClassNameDetector

  def set_picture
    @resource = set_resource
    @resource.update params.require(param_name).permit(:picture)
    flash.now[:notice] = t('notice.picture_update')
    render 'gaku/admin/shared/set_picture'
  end

  def remove_picture
    @resource = set_resource
    @resource.update(picture: nil)
    flash.now[:notice] = t('notice.picture_remove')
    render 'gaku/admin/shared/remove_picture'
  end

  private

  def set_resource
    instance_variable_set("@#{class_name_underscored}", class_name.constantize.find(params[:id]))
  end

  def param_name
    controller_name.singularize.to_sym
  end

end

Version data entries

16 entries across 16 versions & 2 rubygems

Version Path
gaku_admin-0.3.0 app/controllers/concerns/admin_picture_controller.rb
gaku_admin-0.3.0.pre.4 app/controllers/concerns/admin_picture_controller.rb
gaku_admin-0.3.0.pre.3 app/controllers/concerns/admin_picture_controller.rb
gaku_admin-0.3.0.pre.2 app/controllers/concerns/admin_picture_controller.rb
gaku_admin-0.3.0.pre.1 app/controllers/concerns/admin_picture_controller.rb
gaku_admin-0.3.0.pre.0 app/controllers/concerns/admin_picture_controller.rb
gaku-0.2.4 admin/app/controllers/concerns/admin_picture_controller.rb
gaku_admin-0.2.4 app/controllers/concerns/admin_picture_controller.rb
gaku-0.2.3 admin/app/controllers/concerns/admin_picture_controller.rb
gaku_admin-0.2.3 app/controllers/concerns/admin_picture_controller.rb
gaku-0.2.2 admin/app/controllers/concerns/admin_picture_controller.rb
gaku_admin-0.2.2 app/controllers/concerns/admin_picture_controller.rb
gaku-0.2.1 admin/app/controllers/concerns/admin_picture_controller.rb
gaku_admin-0.2.1 app/controllers/concerns/admin_picture_controller.rb
gaku-0.2.0 admin/app/controllers/concerns/admin_picture_controller.rb
gaku_admin-0.2.0 app/controllers/concerns/admin_picture_controller.rb