0
請幫我弄清楚我在這裏做錯了什麼!我正在使用s3_direct_upload將基本映像上載到Amazon S3,然後使用POST創建記錄。我可以在網絡標籤(firebug)中看到它正在POST'd。但是,我不確定爲什麼params沒有被添加到數據庫中。Rails - Params未被添加到模型中?
這是我得到回:
Started POST "/choices" for 127.0.0.1 at 2013-10-02 17:36:10 -0700
Processing by ChoicesController#create as */*
Parameters: {"url"=>"https://mybucket.s3.amazonaws.com/uploads%2F1380760569802-bneiuk2ghf4-22e59d1c8959be731bc71e31f0a9d7c6%2Fslide0003_image002.jpg",
"filepath"=>"/uploads%2F1380760569802-bneiuk2ghf4-22e59d1c8959be731bc71e31f0a9d7c6%2Fslide0003_image002.jpg",
"filename"=>"slide0003_image002.jpg",
"filesize"=>"73930",
"filetype"=>"image/jpeg",
"unique_id"=>"bneiuk2ghf4",
"choice"=>{
"image"=>"https://mybucket.s3.amazonaws.com/uploads%2F1380760569802-bneiuk2ghf4-22e59d1c8959be731bc71e31f0a9d7c6%2Fslide0003_image002.jpg"
}
}
(0.3ms) BEGIN
(0.4ms) ROLLBACK
Rendered choices/create.js.erb (0.1ms)
Completed 200 OK in 16ms (Views: 6.2ms | ActiveRecord: 0.6ms)
# app/controllers/choice.rb
def create
@choice = Choice.create(choice_params)
end
def choice_params
params.require(:choice).permit!
end
然後我的形式(一些HTML略去了):
#app/views/new.html.erb
<%= s3_uploader_form callback_url: choices_url, callback_param: "choice[image]", id: "s3-uploader" do %>
<%= file_field_tag :file, multiple: true %>
<% end %>
任何幫助將是巨大的!
''Choise'模型對'create'的期望是什麼?'require'只返回一個'{「image」=>「https:// ...」}'你的「選擇」模式是否期待這個單一領域?你的模型正在回滾 – Cristopher