【发布时间】:2013-09-29 17:26:23
【问题描述】:
我的用户模型没有:name 字段,但我想在我的注册表单中包含一个:name 字段,该字段将用于在after_create 中创建另一个模型的记录。
class User < ActiveRecord::Base
after_create :create_thing
private
def create_thing
@thing = Thing.new
@thing.name = <here's where I need help>
@thing.save!
end
end
如何从注册表单中获取姓名?
【问题讨论】:
-
我的标题可能是错误的,所以请随时提出更好的建议。
-
我在这里找到了答案:stackoverflow.com/a/17384426/519632
标签: ruby-on-rails ruby devise ruby-on-rails-4 virtual-attribute