Edit: Manuel found a better solution
class ActiveRecord::Associations::CollectionProxy
alias_method :add, :<<
end
Original solution:
This should help you get started. This is not perfect.
class ActiveRecord::Relation
def add(attrs)
create attrs
end
end
, , , :
1.9.3p194 :006 > Artist.create(:first_name => "Kyle", :last_name => "G", :email => "foo@bar.com")
=> #<Artist id: 5, first_name: "Kyle", last_name: "G", nickname: nil, email: "foo@bar.com", created_at: "2012-08-16 04:08:30", updated_at: "2012-08-16 04:08:30", profile_image_id: nil, active: true, bio: nil>
1.9.3p194 :007 > Artist.first.posts.count
=> 0
1.9.3p194 :008 > Artist.first.posts.add :title => "Foo", :body => "Bar"
=> #<Post id: 12, title: "Foo", body: "Bar", artist_id: 5, created_at: "2012-08-16 04:08:48", updated_at: "2012-08-16 04:08:48">
1.9.3p194 :009 > Artist.first.posts.count
=> 1