Skip to content
notahat edited this page Aug 23, 2010 · 10 revisions

Once you’ve defined a blueprint for a class, you use the make method to construct objects of that class.

Post.make

Overriding Attributes

You can override attributes defined in the blueprint by passing them in to make.

Post.make(:title => "Custom Title")

Making Multiple Objects

You can make an array of several objects by passing a count to make.

Post.make(3) # Returns an array of 3 posts.

make!

If you’re making an ActiveRecord object, and you want it to be saved to the database, call make!.

Post.make!  # Makes and saves a post

Read more about [[Make!]]
Clone this wiki locally