Sha256: d16b7a2bfc02101fd8c1065db8e4b7aef379d1d41a804208d26fe37c90a141b5

Contents?: true

Size: 799 Bytes

Versions: 5

Compression:

Stored size: 799 Bytes

Contents

require "redactor-rails"

class RedactorRails::PicturesController < ApplicationController
  before_filter :redactor_authenticate_user! if RedactorRails.picture_model.new.respond_to?(RedactorRails.devise_user)

  def index
    @pictures = RedactorRails.picture_model.all
    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
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
th_simple_content_management-0.2.7 app/controllers/redactor_rails/pictures_controller.rb
th_simple_content_management-0.2.6 app/controllers/redactor_rails/pictures_controller.rb
th_simple_content_management-0.2.5 app/controllers/redactor_rails/pictures_controller.rb
th_simple_content_management-0.2.4 app/controllers/redactor_rails/pictures_controller.rb
th_simple_content_management-0.2.3 app/controllers/redactor_rails/pictures_controller.rb