My User model doesn't have a :name
field but I want to include a :name
field in my sign up form which will be used to create a record of another model in an 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
How can I get the name from the sign up form?
In your model add attr_accessor for name
attr_accessor :name
This will allow you to add it to a form and use it to generate the proper data in your after_create