I want to associate an array of objects with another object without specifying an id while I'm building the array. I'm pretty sure I've seen this done before, but can't find it.
class User < ActiveRecord::Base
has_many :companies
has_many :job_groups
end
class Job < ActiveRecord::Base
belongs_to :job_group
end
class JobGroup < ActiveRecord::Base
belongs_to :user
has_many :jobs
end
Company.rb
def self.user_links(user)
job_group = JobGroup.create(user_id: user.id)
user.companies.each do |c|
links = c.find_links
job_group << links
end
end
Links comes back as a collection of links and I want to associate it to a job group.
I get a NoMethodError: undefined method `<<' for