Skip to content

Instantly share code, notes, and snippets.

@amite
Last active December 10, 2015 14:48
Show Gist options
  • Save amite/4450506 to your computer and use it in GitHub Desktop.
Save amite/4450506 to your computer and use it in GitHub Desktop.
c.profile_datum
I have a client class
````
class Client < ActiveRecord::Base
attr_accessible :name, :notetag
has_many :profile_datum
end
````
..and a ProfileDatum class
````
class ProfileDatum < ActiveRecord::Base
belongs_to :client, :dependent => :delete
attr_accessible :address, :emailid, :notes, :phone, :client_id
end
````
I create objects like so:
p1 = ProfileDatum.create(:address => "Mumbai on the manger", :notes => "ever work with him", emailid: "six@dfg.com", :phone => "3434673453")
c = Client.find(2) #this exists
And then I try to associate like this: `c << p1` sometimes it works but most times it doesn't.
When it works,I try to associate like so:
`c.profile_datum` and it doesn't work #undefined method `profile_datum' for #<Array:>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment