我已经设定了设计。我只在第一个实例中添加了数据库身份验证。我能够填写表单并将其添加到我的数据库中。然后我添加了omniauth,现在,当我尝试使用表单注册时,而不是社交媒体选项,我得到一个禁止属性错误。
我的观点是:
<% if user_signed_in? %>
<li>
<%= link_to('Edit registration', edit_user_registration_path) %>
</li>
<% else %>
<li>
<%= link_to 'Register', new_user_registration_path, :remote => true, 'data-toggle' => "modal", 'data-target' => "#myModal", :method => 'get' %>
</li>
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h4 class="modal-title" id="myModalLabel">Request an invite</h4>
</div>
<div class="modal-body">
<%- if devise_mapping.omniauthable? %>
<div class="facebookauth"> <%= link_to "Register with Facebook", user_omniauth_authorize_path(:facebook) %></div>
<br />
<% end -%>
<%- if devise_mapping.omniauthable? %>
<div class="linkedinauth"> <%= link_to "Register with LinkedIn", user_omniauth_authorize_path(:linkedin) %></div>
<br />
<% end -%>
</div>
<div class="modal-footer">
<%= simple_form_for(resource, as: resource_name, url: registration_path(resource_name)) do |f| %>
<%= f.error_notification %>
<div class="form-inputs" style="padding-left:15%; text-align:left;">
<%= f.input :first_name, required: true, autofocus: true %>
<%= f.input :last_name, required: true, autofocus: true %>
<%= f.input :email, required: true, autofocus: true %>
<%= f.input :password, required: true %>
<%= f.input :password_confirmation, required: true %>
</div>
<div class="form-actions" style="padding-left:15%; padding-top:5%; text-align:left;">
<%= f.button :submit, "Register" %><% end %>
</div>
</div>
</div>
</div>
</div>
<% end %>
我的应用程序控制器有:
def configure_permitted_parameters
devise_parameter_sanitizer.for(:sign_up) { |u| u.permit( :first_name, :last_name, :email, :password, :password_confirmation) }
devise_parameter_sanitizer.for(:sign_in) { |u| u.permit( :email, :password, :remember_me) }
end
我刚尝试将此添加到我的user / registrations_controller中,但它没有帮助。
def user_params
params.require(:user).permit(:first_name, :last_name, :email, :password, :password_confirmation )
end
我想知道它是否因为我的数据库中没有字段用于密码或密码确认?我已加密密码&#39;。
非常感谢任何帮助。
谢谢