Im having a problem creating a devise user using a custom form. Whenever I submit the form I get an error saying the email and password fields cant be blank, It seems that the problem is something to do with the parameters not being permitted. I Have tried creating my own sign_up_params method to permit them manually but it still doesn't work and keep seeing the error.
Here is my code:
This is the form I am submitting:
<div class="panel panel-default">
<div class="panel-heading">
<h4>Sign Up</h4>
</div>
<div class="panel-body">
<%= form_for resource, url: user_registration_path do |f| %>
<%= devise_error_messages! %>
<div class="form-group row">
<%= f.label :email, "Email: ", class: "col-sm-2" %>
<div class="col-sm-10">
<%= f.email_field :email, class: 'form-control' %>
</div>
</div>
<div class="form-group row">
<%= f.label :password, "Password: ", class: "col-sm-2 col-form-label" %>
<div class="col-sm-10">
<%= f.password_field :password, class: 'form-control' %>
</div>
</div>
<div class="form-group row">
<%= f.label :password_confirmation, "Confirmation: ", class: "col-sm-2 col-form-label" %>
<div class="col-sm-10">
<%= f.password_field :password_confirmation, class: 'form-control' %>
</div>
</div>
<%= f.submit "Sign Up", class: 'btn btn-primary' %>
<% end %>
</div>
</div>
And this is the controller:
class Users::RegistrationsController < Devise::RegistrationsController
include DeviseHelper
def new
end
protected
def sign_up_params
params.require(:user).permit(:email, :password, :password_confirmation)
end
end
Also my routes file:
Rails.application.routes.draw do
root 'users/registrations#new'
devise_for :users, controllers: {registrations: 'users/registrations', sessions: 'users/sessions'}
end
This is really starting to bug me now as Ive set up devise plenty of times before and never had this issue. If anyone could help me out here it would be really appreciated
Aucun commentaire:
Enregistrer un commentaire