ruby on rails - skip authentication for CKeditor? -
i using ckeditor in rails app. works pretty well, did not manage photo upload/brows/send server work !
i using cancan , getting cancan::authorizationnotperformed @ /pictures
, after commenting out config.authorize_with :cancan
in config/initializers/ckeditor.rb
so thought uncommenting config.authorize_with :cancan
, using skip_authorization_check
, don't know use it! new rails.
i pretty tried can !
any help/leads/tips please ?
looking @ ckeditor/pictures_controller.rb
of gem gives idea how solve issue. (use bundle open ckeditor
root directory of app, navigate app/controller/ckeditor/
)
so, create ckeditor/pictures_controller.rb
in rails app content:
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
the key solution load_and_authorize_resource
, authorize_resource
, create
method, you'll able upload pictures.
the destroy
method gets called when want delete uploaded images.