/ / DEVISE dodatkowe pole nie jest zapisywane w bazie danych - ruby-on-rails, devise

ODKRYJ dodatkowe pole nie jest zapisywane w bazie danych - wymyśl ruby-on-rail

Próbuję dodać dodatkowe pole w moim formularzu urządzenia w następujący sposób:

<%= form_for(resource, as: resource_name, url: registration_path(resource_name)) do |f| %>
<%= devise_error_messages! %>

<div class="user_field">
<div class="email">
<%= f.label :email %><br />
</div>
<%= f.email_field :email, autofocus: true, autocomplete: "email"%>
</div>

<div class="pass_field">
<div class="password_field">
<%= f.label :password %>
<% if @minimum_password_length %>
<em class = "minimum">(<%= @minimum_password_length %> characters minimum)</em>
<% end %><br />
</div>
<%= f.password_field :password, autocomplete: "off" %>
</div>

<div class="field">
<div class="confirmation_field" input type = "hidden">
<%= f.label :password_confirmation %><br />
<%= f.password_field :password_confirmation, autocomplete: "off" %>
</div>
</div>

<input type="hidden" id="public_key" name="public_key" value="" />
<script type="text/javascript">
document.getElementById("public_key").value = getkey();
</script>

Muszę zezwolić na dodatkowe pole, więc tworzę nowy inicjalizator devise_permitted_parameters.rb w ten sposób

module DevisePermittedParameters
extend ActiveSupport::Concern

included do
before_filter :configure_permitted_parameters
end

protected

def configure_permitted_parameters
devise_parameter_sanitizer.permit(:sign_up, keys: [:email, :password, :password_confirmation])
end

end

DeviseController.send :include, DevisePermittedParameters

Wynik jest następujący:

Parameters: {"utf8"=>"✓", "authenticity_token"=>"8kB8VeA7pvoK0ROvfwwvibyyBUY/FOEHHYDYJbaBVz7+D2O3HrTYQihU1u8ePYC7nxH8qI2bJpWBjX2NZE0XIA==", "user"=>{"email"=>"wtgwg@gmail.com", "password"=>"[FILTERED]", "password_confirmation"=>"[FILTERED]"}, "public_key"=>"qEqGEPmShqM27Gc9CtYPfliPCRI7TQG3xTLZtl3ccIqQJwrvWS6jjZxkiJoM8fD/F4fL2y5xLH5S0Ye5LUiQJQ3SXqrGq1wbRwzEX1Y3GvV1dnNfwBcWvDkigQPvX11MUbzjf3Xiqf+1AtIaWY2+AB04Xou79BEgOtSSc8GDob0=", "commit"=>"Sign up"}

(0,2 ms) rozpoczęcie transakcji Użytkownik istnieje (0.3 ms) WYBIERZ 1 JAKO jeden Z „użytkowników” GDZIE „użytkownicy”. „E-mail” =? LIMIT? [["e-mail", "wtgwg@gmail.com"], ["LIMIT", 1]] SQL (1.1ms) INSERT INTO "users" ("email", "encrypted_password", "created_at", "updated_at") VALUES (?,?,?,?) [["Email", "hey"], [" encrypted_password "," $ 2a $ 11 $ ew.ubHvxuvMrTHsuUqA8xu7ND7Xj3oGtNNR9YkziamJwPldsqvx22 "], [" created_at "," 2018-04-10 17: 17: 07.819645 "], [" updated_at ": 17.04.2018: 10.04.2018: 17.04.2018: ]]

Problem polega na tym, że plik public_key jest zapisywany. Proszę o pomoc?

Odpowiedzi:

0 dla odpowiedzi № 1

spróbuj tego w formie

<%= f.text_field :public_key,id: "public_key" ,class: "hidden", value: "" %>

zamiast

<input type="hidden" id="public_key" name="public_key" value="" />