2017-06-14 32 views
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}... 

回答

0

它僅過濾日誌中。這是由於安全。

您可以自定義它像這樣寫:How to filter parameters in rails?

+0

謝謝。我在這裏看到多個選項。我想在控制器內構建,或者我應該使用模型。哪個最好? – emm

+0

錯誤警報...我仍然可以在控制器中詢問param:user_password_changed。都好 – emm