I have an object called a tag
which has_many :tweets
. The tweet
also has a corresponding belongs_to
.
If I'm generating a tweet to save in the tag
model like so:
new_tweet = Tweet.new
new_tweet.favorite_count = tweet.favorite_count
new_tweet.filter_level = tweet.filter_level
new_tweet.retweet_count = tweet.retweet_count
new_tweet.text = tweet.text
new_tweet.tweeted_at = tweet.created_at
new_tweet.created_at = DateTime.strptime tweet.created_at.to_s, '%Y-%m-%d %H:%M:%S %z'
new_tweet.save
How do I set that tweets parent to be the current tag? Would I do something like this?
new_tweet.tag = self
I tried this and it didn't work, whats a better solution? Thanks for your help.