Ruby on rails 表单中的Rails用户类型选择,用于单表继承的设计注册
我想让用户可以在向Desive注册时选择他们的“类型”。我是否需要为每个“类型”的用户提供不同的注册表,或者我可以使用一个注册表 一切都很基本:Ruby on rails 表单中的Rails用户类型选择,用于单表继承的设计注册,ruby-on-rails,ruby-on-rails-3,forms,devise,single-table-inheritance,Ruby On Rails,Ruby On Rails 3,Forms,Devise,Single Table Inheritance,我想让用户可以在向Desive注册时选择他们的“类型”。我是否需要为每个“类型”的用户提供不同的注册表,或者我可以使用一个注册表 一切都很基本: class User < ActiveRecord::Base ... end class Therapist < User end class Doctor < User end class用户 一旦用户完成此表单,我将让他们填写另一个特定于其用户“类型”的表单。基本上,我的问题是,标签的形式_是什么样的,以区分用户是治疗师
class User < ActiveRecord::Base
...
end
class Therapist < User
end
class Doctor < User
end
class用户
表单如下所示:
<%= 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 %>
resource\u name,:url=>注册路径(resource\u na
我)做| f |%>
正确%>
一旦用户完成此表单,我将让他们填写另一个特定于其用户“类型”的表单。基本上,我的问题是,标签的形式_是什么样的,以区分用户是治疗师还是医生
非常感谢您的帮助或指导 如果您询问注册表单中的类型,以便根据此处指定的类型加载下一个表单,该怎么办
<%= 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 %>
resource\u name,:url=>注册路径(resource\u na
我)做| f |%>
正确%>
问题已解决。这正是我想做的。非常感谢。