0

I would like to make it possible for a User to select their "type" upon registration with devise. Do I need different registration forms for each "type" of User, or can I use one registration form?

Everything is pretty basic:

class User < ActiveRecord::Base
...
end

class Therapist < User
end

class Doctor < User
end

The form looks like this:

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

<div><%= f.label :email %>
<%= f.email_field :email, :autofocus => true %></div>

<div><%= f.label :password %>
<%= f.password_field :password %></div>

<div><%= f.label :password_confirmation %>
<%= f.password_field :password_confirmation %></div>

<div><%= f.submit "Sign up" %></div>
<% end %>

Once the User completes this form, I was going to have them fill out another form specific to their User "type". Basically, my question is, what would the form_for tag look like to distinguish a user as a Therapist or Doctor?

Any help or guidance is greatly appreciated.

4

1 回答 1

1

如果您在注册表单中询问类型,以便您可以根据他们在此处指定的类型加载下一个表单怎么办

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

    <div><%= f.label :email %>
    <%= f.email_field :email, :autofocus => true %></div>

    <div><%= f.label :password %>
    <%= f.password_field :password %></div>

    <div><%= f.label :password_confirmation %>
    <%= f.password_field :password_confirmation %></div>


    <div><%= f.label :type %>
    <%= f.select :type, options_for_select(%w[User Therapist Doctor]) %></div>

    <div><%= f.submit "Sign up" %></div>
  <% end %>
于 2013-10-18T21:40:18.823 回答