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
2 changes: 1 addition & 1 deletion app/controller/redactor2_rails/files_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def create
end

if @file.save
render json: { url: @file.url, name: @file.filename }
render json: { file: { url: @file.url, name: @file.filename } }
else
render json: { error: @file.errors }
end
Expand Down
2 changes: 1 addition & 1 deletion app/controller/redactor2_rails/images_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def create
end

if @image.save
render json: { id: @image.id, url: @image.url(:content) }
render json: { file: { id: @image.id, url: @image.url(:content) } }
else
render json: { error: @image.errors }
end
Expand Down
8 changes: 6 additions & 2 deletions lib/generators/redactor2/templates/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,13 @@ $(function () {
$.Redactor.settings = {
//plugins: ['source', 'fullscreen', 'textdirection', 'clips'],
imageUpload: '/redactor2_rails/images',
imageUploadFields: params,
imageData: {
elements: params
},
fileUpload: '/redactor2_rails/files',
fileUploadFields: params
fileData: {
elements: params
},
};
// Initialize Redactor
$('.redactor').redactor();
Expand Down
4 changes: 3 additions & 1 deletion lib/redactor2_rails/http.rb
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,10 @@ def body
# file upload hash with UploadedFile objects
def self.normalize_param(*args)
value = args.first
if Hash === value && value.has_key?(:tempfile)
if Hash == value && value.has_key?(:tempfile)
UploadedFile.new(value)
elsif value.is_a?(Array)
value.first
elsif value.is_a?(String)
QqFile.new(*args)
else
Expand Down