0
在我的ERB我:Ruby on Rails的4複選框返回過濾
<td>
<%= user_field.label :user_password_changed, "Do you wish to change your password?" %>
<%= user_field.check_box(:user_password_changed) %>
</td>
與此相關的領域我有jQuery的工作正常:
$("input[type=checkbox]").on('change', function() {
var getid = this.id;
if (getid.includes('user_password_changed')) {
if (this.checked == true) { $("div#change_password").css("display", "block"); }
else { $("div#change_password").css("display", "none");}
} });
在相關模型,用戶,user_password_changed不是一個領域。所以我用attr_accessor,在那裏我有:
attr_accessor :user_password_changed
當我發佈PARAMS是:
"user"=>{"role_id"=>"1", "user_changed"=>"1", "user_id"=>"50", "community_name"=>"foo", "username"=>"foo", "user_alias"=>"foo", "user_password_changed"=>"[FILTERED]", "password"=>"[FILTERED]", "password_confirmation"=>"[FILTERED]", "email"=>"foo", "user_type"=>foo}...
謝謝。我在這裏看到多個選項。我想在控制器內構建,或者我應該使用模型。哪個最好? – emm
錯誤警報...我仍然可以在控制器中詢問param:user_password_changed。都好 – emm