Class: RedactorRails::PicturesController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- RedactorRails::PicturesController
- Defined in:
- app/controller/redactor_rails/pictures_controller.rb
Instance Method Summary collapse
- #create ⇒ Object
-
#index ⇒ Object
before_filter :redactor_authenticate_user!.
Instance Method Details
#create ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'app/controller/redactor_rails/pictures_controller.rb', line 10 def create @picture = RedactorRails.picture_model.new file = params[:file] @picture.data = RedactorRails::Http.normalize_param(file, request) if @picture.respond_to?(RedactorRails.devise_user) @picture.send("#{RedactorRails.devise_user}=", redactor_current_user) @picture.assetable = redactor_current_user end if @picture.save render :text => { :filelink => @picture.url }.to_json else render json: { error: @picture.errors } end end |
#index ⇒ Object
before_filter :redactor_authenticate_user!
4 5 6 7 8 |
# File 'app/controller/redactor_rails/pictures_controller.rb', line 4 def index @pictures = RedactorRails.picture_model.where( RedactorRails.picture_model.new.respond_to?(RedactorRails.devise_user) ? { RedactorRails.devise_user_key => redactor_current_user.id } : { }) render :json => @pictures.to_json end |