Files
nairobi/app/controllers/ckeditor/pictures_controller.rb
Raúl Fuentes d574657b77 Fixes for the review made by @javierm
this commit will be merged with the others when the chages
are accepted
2018-09-12 12:35:28 +02:00

39 lines
933 B
Ruby

class Ckeditor::PicturesController < Ckeditor::ApplicationController
load_and_authorize_resource
def index
@pictures = Ckeditor.picture_adapter.find_all(ckeditor_pictures_scope)
@pictures = Ckeditor::Paginatable.new(@pictures).page(params[:page])
respond_to do |format|
format.html { render :layout => @pictures.first_page? }
end
end
def create
@picture = Ckeditor.picture_model.new(user_id: current_user.id)
respond_with_asset(@picture)
end
def destroy
@picture.destroy
respond_to do |format|
format.html { redirect_to pictures_path }
format.json { render :nothing => true, :status => 204 }
end
end
protected
def find_asset
@picture = Ckeditor.picture_adapter.get!(params[:id])
end
def authorize_resource
model = @picture || Ckeditor.picture_model
@authorization_adapter.try(:authorize, params[:action], model)
end
end