Question

I already have normal users signing up and signing in using devise . What i was planning on doing was make 2 categories(let's say A & B) for users . So i ran the command rails generate devise A and views for the same . When i open up A/sign_up , this is what comes up

NoMethodError in Devise/registrations#new

Showing /app/views/devise/registrations/new.html.erb where line #11 raised:

undefined method `name' for #<A:0xc654e54>

Extracted source (around line #11):

    <%= simple_form_for(resource, :as => resource_name, :url => registration_path(resource_name), :validate => true) do |f| %>

      <div>
        <%= f.text_field :name, :validate => { :presence => true }, :placeholder => 'Full Name' %>

     </div>

Please do suggest what's causing this to appear . Using rails 3.2.8 , devise 2.2.3 and ruby 1.9.3 . Thanks in advance :)

Was it helpful?

Solution

undefined method `name' for #

Means that Devise is looking for a model A that has a method or database column :name.

This will through an error unless you have a Model called A, with devise :registerable in the model definition, or is model A has no :name method of column.

Devise is typically used with a model, if you want two types of users, I suggest you make two separate models UserA and UserB and add Devise separately to each of them.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top