Sha256: 14cd2fa781d626b4209fdfff3813d8e7eec3c9f431f0f318815f26474694438e
Contents?: true
Size: 1002 Bytes
Versions: 5
Compression:
Stored size: 1002 Bytes
Contents
class RedactorRails::PicturesController < ApplicationController before_filter :redactor_authenticate_user! 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 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 :nothing => true end end private def redactor_authenticate_user! if RedactorRails.picture_model.new.respond_to?(RedactorRails.devise_user) super end end end
Version data entries
5 entries across 5 versions & 1 rubygems