Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions app/controller/redactor_rails/documents_controller.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
class RedactorRails::DocumentsController < ApplicationController
before_filter :redactor_authenticate_user!
before_action :redactor_authenticate_user!

def index
@documents = RedactorRails.document_model.where(
Expand All @@ -18,9 +18,10 @@ def create
end

if @document.save
render :text => { :filelink => @document.url, :filename => @document.filename }.to_json
@document.reload
render json: { filelink: @document.url, filename: @document.data_file_name }
else
render json: { error: @document.errors }
render json: { error: @document.errors }, status: :unprocessable_entity
end
end

Expand Down
8 changes: 5 additions & 3 deletions app/controller/redactor_rails/pictures_controller.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
class RedactorRails::PicturesController < ApplicationController
before_filter :redactor_authenticate_user!
before_action :redactor_authenticate_user!

def index
@pictures = RedactorRails.picture_model.where(
Expand All @@ -18,9 +18,11 @@ def create
end

if @picture.save
render :text => { :filelink => @picture.url }.to_json
# Necessary else the URL comes back as nil
@picture.reload
render json: { filelink: @picture.url(:content) }
else
render json: { error: @picture.errors }
render json: { error: @picture.errors }, status: :unprocessable_entity
end
end

Expand Down
4 changes: 2 additions & 2 deletions lib/redactor-rails/orm/active_record.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ def self.extended(base)
base.class_eval do
self.table_name = "redactor_assets"

belongs_to :assetable, :polymorphic => true
belongs_to RedactorRails.devise_user, :foreign_key => RedactorRails.devise_user_key
belongs_to :assetable, polymorphic: true, optional: true
belongs_to RedactorRails.devise_user, :foreign_key => RedactorRails.devise_user_key, :optional => true

if defined?(ActiveModel::ForbiddenAttributesProtection) && base.ancestors.include?(ActiveModel::ForbiddenAttributesProtection)
# Ok
Expand Down
2 changes: 1 addition & 1 deletion lib/redactor-rails/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module RedactorRails
VERSION = "0.5.0"
VERSION = "0.8.1"
end
Loading