Use of push_with_attributes

Hi,

I have a model class called Page and a corresponding pages table in the
db.

Is there a way to do Page.new without actually creating a corresponding
record in the table? I want to set some values in it and then pass it to
the add_content_component() method in the class below which calls
push_with_attributes() which will actually create the record in the db?

class Page < ActiveRecord::Base
has_and_belongs_to_many :contentcomponents


def add_content_component(content_component)
pos = Integer(contentcomponents.size) + 1
contentcomponents.push_with_attributes(content_component, :pos =>
pos)
end

end

Or am I all messed up and I should be taking a different approach?

Thanks!

Paul

If I understand you correctly all you need to do is:

page = Page.new(attribute_hash)

Then pass the “page” variable wherever you need it to go. It won’t be
created in the database until you do page.save

Also, I believe push_with_attributes has been deprecated in favor of
has_many :through. Check it out, it may make things ismpler for you.