-1
我有一個問題,它沒有收到array value
當我試圖提交array value
其中我使用checkbox
。導軌未收到陣列值強參數
這裏是我的代碼:
這是migration
文件:
create_table :users do |t|
t.string :email, null: false, default: ""
t.string :encrypted_password, null: false, default: ""
t.text :receive_mail, array: true, default: []
...
這是function
我把array attributes
:
def configure_sign_up_params
devise_parameter_sanitizer.permit(:sign_up, keys: [
:address,
{receive_mail: []}
])
end
這是view
文件:
<div class="field">
<%= f.collection_check_boxes(:receive_mail, [[0, "receive new article"], [1, "receive new ebook"]], :first, :last, include_hidden: false) do |b| %>
<%= b.label {b.check_box + b.text} %>
<% end %>
</div>
當我提出,我檢查params
,它有一個價值"receive_mail"=>["0", "1"]
,但是當我檢查時,它permited
,它總是返回"receive_mail"=>[]
。
我不明白爲什麼它沒有收到價值。
任何幫助將不勝感激。
謝謝你的回答,我試過了,但沒有奏效。 –