[Rails] Re: Populate default data in tables when object is created
Juan Kinunt wrote:
> For example, a Company has_many Threats and a Threat belongs_to a
> Company and I want to populate the table Threats with some default
> threats when a Company is created.
Precisely! The default action for a 'company creation' step is to
manufacture n threats associated with that company. The behavior of
defaulting those records for each company as it is created belongs in
the Company model (in my opinion).
If you have different 'default' threats depending on what kind of
company is created (threats are dependent on a company attribute), then
all the more reason for that defaulting logic to be contained in the
company model.
> I don't use the same threats for each
> company because each company can add, delete and modify their threats as
> they want, so I don't want to share threats. If you think this can be
> done differently better any hint will be really appreciated :)
You would create an instance of each desired threat type for each
company when the company was created. No threat sharing was intended in
my earlier response, sorry for the ambiguity.
--
Posted via http://www.ruby-forum.com/.
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home