Read more

Machinist blueprints: Do not set associations without blocks

Dominik Schöler
July 29, 2014Software engineer at makandra GmbH

TL;DR In blueprints, always wrap associations in blocks.

# Broken
Task.blueprint(:vacation) do
  project Project.make(:vacation)
  hours 8
  accounting_method 'none'
end
# Correct
Task.blueprint(:vacation) do
  project { Project.make(:vacation) }
  hours 8
  accounting_method 'none'
end
Illustration online protection

Rails Long Term Support

Rails LTS provides security patches for old versions of Ruby on Rails (2.3, 3.2, 4.2 and 5.2)

  • Prevents you from data breaches and liability risks
  • Upgrade at your own pace
  • Works with modern Rubies
Read more Show archive.org snapshot

Without the block, Project.make will only run once when the blueprint is parsed (usually when RSpec is loaded), which is not what you want.

Posted by Dominik Schöler to makandra dev (2014-07-29 16:55)