On Apr 15, 2015, at 4:34 PM, Philippe Demaria <demaria.phili...@lfbogota.com> 
wrote:
> 
> Ces 2 types d'exercices peuvent ils être dans le même model ?

I believe so, however I have no experience in this specific domain. Just a 
suggestion, I assume you already have some way to represent a formula in the 
database, so perhaps you could have an attribute specifying whether 
coefficients are fixed, or to be varied. (Or even allow it to be specified 
per-coefficient.)

So in that case, your model logic for fetching, validation, and so on, would 
have to take into account which coefficients to assign a varying value (and 
when).

It seems to me that a view would receive a model object with coefficients 
already specified, and would have no need to know whether the coefficients are 
fixed or not, so the view code would not change. Similarly, the controller 
would depend on the model for initialization before sending to the view, and 
validation on submission, so could be the same code in either case.

It's also possible to consider using inheritance, a base class for the common 
logic, and inherited classes with specific overrides. RoR has facilities for 
dealing with this. I personally don't think it's needed here; I mention it only 
because I don't know the details of your model representation, so it's possible 
that inheritance is more appropriate to your needs than I realize.

> Suis je clair ?

I think so. It seems to me your problem is more with representation of the 
underlying model, and that any RoR questions you may have other than creating 
the mode will be relatively simple.

-- 
Scott Ribe
scott_r...@elevated-dev.com
http://www.elevated-dev.com/
https://www.linkedin.com/in/scottribe/
(303) 722-0567 voice





-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to rubyonrails-talk+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/2E89293C-3FAD-4B83-A22A-509E54DC3A52%40elevated-dev.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to