The .build method is the ActiveRecord method that is used to create a new record based on the has_many relationships in your model.
So let's say:
User has_many tweets
Then you can use
user.tweets.build(tweet_id)
This will create a new tweet in the tweet table associated with this user. He will also return this object.
You probably want to put params tweet_id in your argument depending on how you implement the application. :)
source share