我正在try 向我的用户模型(使用devise
gem)和Rails 4添加一个full_name
字段/列.
大多数例子都是在线recommend using attr_accessible,但在Rails 4中,这听起来应该以不同的方式处理.
我如何将full_name
添加到我的用户模型中?我已经成功运行了migrations.
File: Migration > add_full_name_to_users
class AddFullNameToUsers < ActiveRecord::Migration
def change
add_column :users, :full_name, :string
end
end
File: Registration > app/views/devise/registration/new.html
.
.
.
<%= form_for(resource, :as => resource_name, :url => registration_path(resource_name)) do |f| %>
<%= devise_error_messages! %>
<%= f.label :full_name %>
<%= f.text_field :full_name, :autofocus => true %>
<%= f.label :email %>
<%= f.email_field :email %>
.
.
.