On Apr 15, 2015, at 4:34 PM, Philippe Demaria
[email protected] 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
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.
(303) 722-0567 voice