Laurie
Laurie

Reputation: 162

TypeError in Devise::RegistrationsController#create

For Devise with Rails 4.2., I am able to sign up users when I turn off confirmation required in my user model but when I turn it back on I get this error.

no implicit conversion of Array into String <

# i.e. OpenSSL::Digest::SHA1#block_length
        def generate_key(salt, key_size=64)
          OpenSSL::PKCS5.pbkdf2_hmac_sha1(@secret, salt, @iterations, key_size)
        end
      end

referring to this line

devise (3.5.10) lib/devise/token_generator.rb:50:in `pbkdf2_hmac_sha1'

I am using mailtrap for my development settings and I am able to get mail in my contact page.

In my user.rb I have
devise :database_authenticatable, :registerable, :recoverable, :rememberable, :trackable, :validatable, :confirmable

My devise initalizer is set exactly the same as another project that works.

In my application controller, I have set parameters

before_action :configure_permitted_parameters, if: :devise_controller? def configure_permitted_parameters devise_parameter_sanitizer.for(:sign_up) { |u| u.permit(:firstname, :lastname, :email, :avatar, :password, :password_confirmation) } end

My views/devise contain the folders (confirmations, mailer, passwords, registrations, sessions, shared, and unlocks.

My devise registrations new is below:

<div class="row">

<%= bootstrap_devise_error_messages! %>
<div class="panel panel-default devise-bs">
  <div class="panel-heading">
    <h4><%= t('.sign_up', :default => "Sign up") %></h4>
  </div>
  <div class="panel-body">
    <%= form_for(resource, :as => resource_name, :url => registration_path(resource_name), html: { role: "form" }) do |f| %>
      <div class="form-group">
        <%= f.label :firstname %>
        <%= f.text_field :firstname, autofocus: true, class: "form-control" %>
      </div>
      <div class="form-group">
        <%= f.label :lastname %>
        <%= f.text_field :lastname, autofocus: true, class: "form-control" %>
      </div>
      <div class="form-group">
        <%= f.label :email %>
        <%= f.email_field :email, autofocus: true, class: "form-control" %>
      </div>
      <div class="form-group">
        <%= f.label :avatar %><br>
        <%= f.file_field :avatar, autofocus: true, class: "form-control" %>
      </div>
      <div class="form-group">
        <%= f.label :password %>
        <% if @minimum_password_length %>
        <em>(<%= @minimum_password_length %> characters minimum)</em>
        <% end %><br />
        <%= f.password_field :password, autocomplete: "off", class: "form-control" %>
      </div>
      <div class="form-group">
        <%= f.label :password_confirmation %>
        <%= f.password_field :password_confirmation, autocomplete: "off", class: "form-control" %>
      </div>
      <%= f.submit t('.sign_up', :default => "Sign up"), class: "btn btn-primary" %>
    <% end %>
  </div>
  <div class="panel-footer">
    <%= render "devise/shared/links" %>
  </div>
</div>

Any tips on what I could be doing wrong, I have spun my wheels for a couple of days. Thanks :)

Upvotes: 1

Views: 300

Answers (1)

Jonathan
Jonathan

Reputation: 11494

Check that your to_json/as_json in your user.rb is working properly.

Upvotes: 0

Related Questions