Sha256: c27b5a24f598c3d4128992ac2cfd88d30274bafb0c6d5e3b97f6c3fb3e2a978f

Contents?: true

Size: 551 Bytes

Versions: 3

Compression:

Stored size: 551 Bytes

Contents

class RedactorRails::BaseController < ApplicationController

  def index
    @redactors = controller_model.order :id 
    render json: @redactors.to_json
  end

  def create
    @redactor = controller_model.new

    file = params[:file]
    @redactor.data = RedactorRails::Http.normalize_param(file, request)

    if @redactor.save
      render text: { filelink: @redactor.url }.to_json
    else
      render nothing: true
    end
  end

  protected

  def controller_model
    self.class.to_s.sub('Controller', '').singularize.constantize
  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
redactor-rails-paperclip-0.4.3 app/controller/redactor_rails/base_controller.rb
redactor-rails-paperclip-0.4.2.1 app/controller/redactor_rails/base_controller.rb
redactor-rails-paperclip-0.4.1 app/controller/redactor_rails/base_controller.rb