-
Type:
Task
-
Resolution: Done
-
Affects Version/s: None
-
Component/s: None
-
None
-
None
-
None
-
None
-
None
-
None
-
None
I have two model's Contact, and User. When I create a new user I am trying to create the contact at the same time. But It is not getting created for some reason. Any ideas on why?
{{`}}ruby
class Contact
include Mongoid::Document
include Mongoid::Timestamps
include Mongoid::MultiParameterAttributes
include Mongoid::Paranoia
include Mongoid::Versioning
- Attr.
attr_accessible :first_name, :last_name, :birthday, :email_addresses_attributes, :phone_numbers_attributes, :relationships_attributes, :addresses_attributes
#Relationships
belongs_to :firm, validate: true
has_one :user # contact information for user
has_many :relationships, autosave: true
has_many :clients
has_many :notes, dependent: :destroy
...
end
class User
include Mongoid::Document
include ActiveModel::SecurePassword
include Mongoid::Timestamps
- Attr.
attr_accessible :contact_id, :contact_attributes, :password, :password_confirmation, :google_tokens
#Relationships
belongs_to :firm, validate: true
belongs_to :contact, validate: true, autosave: true
has_one :user_type
embeds_many :histories
- Nested Attrs
accepts_nested_attributes_for :contact
...
end