Class: RedactorRails::PicturesController

Inherits:
ApplicationController
  • Object
show all
Defined in:
app/controller/redactor_rails/pictures_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



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.has_attribute?(:"#{RedactorRails.devise_user_key}")
    @picture.send("#{RedactorRails.devise_user}=", redactor_current_user)
    @picture.assetable = redactor_current_user
  end

  if @picture.save
    render json: { filelink: @picture.url(:content) }
  else
    render json: { error: @picture.errors }
  end
end

#indexObject



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