I'm very new to machinist and I'm trying to use it to setup an habtm
association between two ActiveRecord entities: IPAddress and Hostname.
My blueprints are:
Sham.address { |num| "192.168.178.#{num}" }
Sham.hostname { |num| "Hostname #{num}" }
IpAddress.blueprint { address }
Hostname.blueprint { hostname }
In order to setup an association between an hostname and three ip addresses
- following the example on the README - I tried to use an helper method:
def make_hostname_with_ips
Hostname.make do |hostname|
3.times { hostname.ips.make }
end
end
BTW, calling the method results in the following exception:
ActiveRecord::RecordNotFound: Couldn't find Ip with ID=1
from
/usr/lib/ruby/gems/1.8/gems/activerecord-2.3.3/lib/active_record/base.rb:1586:in
`find_one'
from
/usr/lib/ruby/gems/1.8/gems/activerecord-2.3.3/lib/active_record/base.rb:1569:in
`find_from_ids'
from
/usr/lib/ruby/gems/1.8/gems/activerecord-2.3.3/lib/active_record/base.rb:616:in
`find'
from
/usr/lib/ruby/gems/1.8/gems/activerecord-2.3.3/lib/active_record/base.rb:2690:in
`reload_without_dirty'
from
/usr/lib/ruby/gems/1.8/gems/activerecord-2.3.3/lib/active_record/dirty.rb:94:in
`reload_without_autosave_associations'
from
/usr/lib/ruby/gems/1.8/gems/activerecord-2.3.3/lib/active_record/autosave_association.rb:191:in
`reload'
from
/home/andrea/src/alca-assetmanager/vendor/plugins/machinist/lib/machinist/active_record.rb:56:in
`make'
from
/usr/lib/ruby/gems/1.8/gems/activerecord-2.3.3/lib/active_record/associations/association_collection.rb:379:in
`send'
from
/usr/lib/ruby/gems/1.8/gems/activerecord-2.3.3/lib/active_record/associations/association_collection.rb:379:in
`method_missing'
from
/usr/lib/ruby/gems/1.8/gems/activerecord-2.3.3/lib/active_record/base.rb:2143:in
`with_scope'
from
/usr/lib/ruby/gems/1.8/gems/activerecord-2.3.3/lib/active_record/associations/association_proxy.rb:206:in
`send'
from
/usr/lib/ruby/gems/1.8/gems/activerecord-2.3.3/lib/active_record/associations/association_proxy.rb:206:in
`with_scope'
from
/usr/lib/ruby/gems/1.8/gems/activerecord-2.3.3/lib/active_record/associations/association_collection.rb:375:in
`method_missing'
from ./features/support/blueprints.rb:54:in
`make_hostname_with_ips'
from ./features/support/blueprints.rb:54:in `times'
from ./features/support/blueprints.rb:54:in
`make_hostname_with_ips'
from
/home/andrea/src/alca-assetmanager/vendor/plugins/machinist/lib/machinist.rb:33:in
`object'
from
/home/andrea/src/alca-assetmanager/vendor/plugins/machinist/lib/machinist/active_record.rb:58:in
`make'
from ./features/support/blueprints.rb:53:in
`make_hostname_with_ips'
I'm using machinist from git and ActiveRecord 2.3.3
Any help will be greatly appreciated!
Regards,
--
Andrea Fazzi @ alca.le.it
Follow me on http://twitter.com/remogatto