我需要添加字段:名称来设计,但我会尝试创建标签,文本字段:名称和添加:名称来设计模型,但我的程序不显示字段:name.I没有任何想法如何解决这个问题?我如何添加字段:用户部分设计的名称?
mycode的模式中用户
class User < ActiveRecord::Base
# Include default devise modules. Others available are:
# :token_authenticatable, :confirmable,
# :lockable, :timeoutable and :omniauthable
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable
# Setup accessible (or protected) attributes for your model
attr_accessible :email, :password, :password_confirmation, :remember_me, :name
# attr_accessible :title, :body
has_many :events, as: :eventable
def to_s
name.present? ? name : email
end
end
,这是用户/注册/ new.html.erb
<h2>Sign up</h2>
<%= form_for(resource, :as => resource_name, :url => registration_path(resource_name)) do |f| %>
<%= devise_error_messages! %>
<div><%= f.label :name %><br />
<%= f.text_field :name %></div>
<div><%= f.label :email %><br />
<%= f.email_field :email %></div>
<div><%= f.label :password %><br />
<%= f.password_field :password %></div>
<div><%= f.label :password_confirmation %><br />
<%= f.password_field :password_confirmation %></div>
<div><%= f.submit "Sign up" %></div>
<% end %>
<%= render "devise/shared/links" %>
我尝试这一点,但没有代码happen.How我做到这一点?
哦,对不起,我的项目中的路径是用户/ registrations/new.html.erb不是'用户',但我会尝试铁轨生成设计:意见用户它什么都没有发生任何想法? – 2013-03-27 08:26:01
'rails generate devise:views'应该创建'app/views/devise/registrations/new.html.erb'。为了确保显示哪个视图,请查看您的日志。如果您感到困惑,您也可以将其粘贴到此处。 – zachar 2013-03-27 08:34:25