small medium large xlarge

31 Mar 2011, 18:15
Mike Howard (1 post)

Where does the ‘product()’ method come from - in the line:

@product = products(:one)

on page 94 of Agile Web Dev, 4th Ed -

03 Apr 2011, 23:37
Pawel Osiczko (2 posts)

Hi Mike,

As they say, convention over configuration, convention being that Rails loads the fixture from tests/fixtures/ automagically when running test task and makes it available for use. In this case, Rails loads test/fixtures/products.yml and makes it available as products object. Lookup on :one, gets you an object corresponding to the YAML record of:

  description: MyText
  image_url: MyString
  price: 9.99

More info on fixtures is available on page 101 of AWD and “rails documentation”:



You must be logged in to comment