tinymce-rails-image-upload을 사용하여 클립으로 이미지를 업로드하고 있습니다 (this demo-app 다음). 이미지를 업로드하려고 할 때 'umpermitted parameters'알림이 표시되고 이미지가 업로드되지 않습니다.주석으로 이미지를 업로드 할 때 허용되지 않는 매개 변수
class TinymceAssetsController < ApplicationController
respond_to :json
def create
geometry = Paperclip::Geometry.from_file params[:file]
question = Question.create params.permit(:file, :alt, :hint)
render json: {
question: {
url: question.file.url,
height: geometry.height.to_i,
width: geometry.width.to_i
}
}, layout: false, content_type: "text/html"
end
end
및 질문 모델 :
class Question < ActiveRecord::Base
has_attached_file :file
end
하고 뷰 :
다음Processing by TinymceAssetsController#create as HTML
Parameters: {"utf8"=>"✓", "authenticity_token"=>"auth token", "hint"=>"", "file"=>#<ActionDispatch::Http::UploadedFile:0x000001025a2780 @tempfile=# <File:/var/folders/t4/86vsrmds42j84r36kwpng7k00000gn/T/RackMultipart20150207- 12522-9rj6xq>, @original_filename="applecash.jpg", @content_type="image/jpeg", @headers="Content-Disposition: form-data; name=\"file\"; filename=\"applecash.jpg\"\r\nContent-Type: image/jpeg\r\n">, "alt"=>""}
Command :: identify -format '%wx%h,%[exif:orientation]' '/var/folders/t4/86vsrmds42j84r36kwpng7k00000gn/T/RackMultipart20150207-12522-9rj6xq[0]' 2>/dev/null
Unpermitted parameters: utf8, authenticity_token
(0.1ms) begin transaction
Question Load (0.5ms) SELECT "questions".* FROM "questions" WHERE (questions.position IS NOT NULL) AND (1 = 1) ORDER BY questions.position DESC LIMIT 1
Binary data inserted for `string` type on column `file_content_type`
SQL (0.8ms) INSERT INTO "questions" ("created_at", "file_content_type", "file_file_name", "file_file_size", "file_updated_at", "position", "updated_at") VALUES (?, ?, ?, ?, ?, ?, ?) [["created_at", Sun, 08 Feb 2015 18:35:07 UTC +00:00], ["file_content_type", "image/jpeg"], ["file_file_name", "timcook.jpg"], ["file_file_size", 120040], ["file_updated_at", Sun, 08 Feb 2015 18:35:07 UTC +00:00], ["position", 9], ["updated_at", Sun, 08 Feb 2015 18:35:07 UTC +00:00]]
(7.3ms) commit transaction
Completed 200 OK in 68ms (Views: 0.6ms | ActiveRecord: 8.7ms)
컨트롤러입니다 : 업로드 모달 쇼 '서버에서 잘못된 응답을 얻었다'
<%= simple_form_for [@comment, Question.new] do |f| %>
<%= f.text_area :body, :class => "tinymce", :rows => 10, :cols => 60 %>
<% end %>
<%= tinymce plugins: ["uploadimage"] %>
일부 매개 변수를 허용하지에 그것은, 괜찮아 허가되지 않은 매개 변수'있도록 : UTF8, authenticity_token' 미리 알림이 아닌 예외입니다. 'question' 모델 인스턴스 오류가 무엇인지 기록해 보시기 바랍니다 : 'logger.debug question.errors.full_messages (질문 후 = question.create params.permit (: file, : alt, : 힌트) 행)' –
Ah , 고맙습니다, 그게 문제를 보여줍니다. 나는 질문 본문의 존재를 확인하고 있었고 그것은 공백이었다. 그러나 이제 오류는 표시되지 않지만 이미지는 여전히 업로드되지 않습니다 (새 출력이있는 편집 된 질문). – user2759575
<% = simple_form_for [@comment, Question.new], : html => {: multipart => true} 형식에': html => {: multipart => true}'옵션을 추가합니다. f | %> 여기에 문제가 있다고 생각합니다 : 'file_content_type' 열에'string '유형의 이진 데이터가 삽입되었습니다. 그리고 아마도 제 제안으로 해결할 수 있습니다. –