Here is my full blueprints.rb file:
require 'machinist/active_record'
#
https://github.com/notahat/machinist/wiki/Blueprints
Company.blueprint do
name { "Digitech" }
acn { "
12345678901" }
end
Staff.blueprint do
username { "t946" }
email { "
mic...@dtcorp.com.au"}
password { "password" }
default_company { company }
end
Here is my full staff model:
class Staff < ActiveRecord::Base
devise :database_authenticatable, :recoverable, :rememberable, :trackable, :validatable
attr_accessible :username, :email, :password, :password_confirmation, :remember_me
has_many :employees
has_many :companies, :through => :employees
belongs_to :default_company, :class_name => "Company"
end
And here is my full Company model
class Company < ActiveRecord::Base
has_many :ledgers
has_many :employees
has_many :staff, :through => :employees
define_index do
indexes :name
set_property :delta => true
end
end
Sorry for not providing enough information in my first post.
If I have the following in my blueprint should this fill in the
association 'default_company_id' in the staff model?
Do I have to call my field 'company_id' instead of
'default_company_id' in the staff table for this automatic association
to work?
Staff.blueprint do
company
end
Instead of doing this link in my blueprints I've been doing it in my
cucumber steps (via Pickle). Is this a better way of creating such a
link?
from
Mick