我的用户模型没有:name
字段,但我想在我的注册表单中包含:name
字段,该字段将用于在after_create
中创建另一个模型的记录。虚拟属性与Devise in Rails 4
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
如何从注册表单中获取名称?
我的标题可能是错的,所以请随时提出一个更好的建议。 –
我在这里找到了我的答案:http://stackoverflow.com/a/17384426/519632 –