mercredi 14 juin 2017

Ruby On Rails 4 checkbox returned as filtered

In my erb I have:

 <td>
 <%= user_field.label :user_password_changed, "Do you wish to change your password?" %>
 <%= user_field.check_box(:user_password_changed) %>
 </td>

Related to this field I have Jquery which works fine:

  $("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");}  
  }   });

In the relevant model, User, user_password_changed is not a field. So I am using attr_accessor, where I have:

 attr_accessor :user_password_changed

When I post the params are:

"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}... 




Aucun commentaire:

Enregistrer un commentaire