看着寶石的ckeditor/pictures_controller.rb
讓你知道如何解決這個問題。 (使用bundle open ckeditor
從您的應用程序的根目錄,然後導航到app/controller/ckeditor/
)
因此,在您對內容的Rails應用程序創建一個ckeditor/pictures_controller.rb
:
class Ckeditor::PicturesController < Ckeditor::ApplicationController
load_and_authorize_resource
def create
@picture = Ckeditor::Picture.new
respond_with_asset(@picture)
end
def destroy
@picture.destroy
respond_with(@picture, :location => pictures_path)
end
protected
def authorize_resource
model = (@picture || Ckeditor::Picture)
@authorization_adapter.try(:authorize, params[:action], model)
end
end
該解決方案的關鍵是load_and_authorize_resource
和authorize_resource
和create
方法,您將可以上傳圖片。
當您想刪除上傳的圖像時,destroy
方法會被調用。
你的ability.rb是怎麼樣的? – Mattherick 2013-04-25 17:08:01