Rails: create lots of almost-duplicate records
I want to write a method that creates a bunch of almost-duplicate records,
just with one or two parameters changed. I'll make a form to control those
parameters, I'm just wondering about how best to write the method, and
where do keep it.
Presently in my document.rb I've written this:
def self.publish(brand, components, template)
brand.users.each do |user|
Document.create(:component_ids => components, :message => 'Message.',
:template_id => template.id, :user_id => user.id)
end
end
It doesn't feel right though. Is there a better way to do this?
Thanks!
No comments:
Post a Comment