Does << create a new record?

Search engine don’t index << so it’s hard to find info about it.

Let’s say I have:

order = order.create
item = Item.new

Will order.items << item create a new entry for the item in DB or not?
I’m having issues.

Hi –

On Sat, 26 Sep 2009, Fernando P. wrote:

Search engine don’t index << so it’s hard to find info about it.

Let’s say I have:

order = order.create
item = Item.new

Will order.items << item create a new entry for the item in DB or not?
I’m having issues.

Yes, it will save the item (assuming Order has many Items, Item
belongs to Order). If it doesn’t, something else is wrong (like the
item not being valid).

David


David A. Black, Director
Ruby Power and Light, LLC (http://www.rubypal.com)
Ruby/Rails training, consulting, mentoring, code review
Book: The Well-Grounded Rubyist (http://www.manning.com/black2)

Yes, it will save the item (assuming Order has many Items, Item
belongs to Order). If it doesn’t, something else is wrong (like the
item not being valid).
Nice catch, one of my items was not valid.

For the future:

go to: “http://api.rubyonrails.org/
use your browser’s find to search for: “<<”

On Sep 26, 3:15 pm, Fernando P. [email protected]

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs