I have a ROR app (in development) I have models based on SQL visuals.
However, I & amp; The updated thoses models are stored in the database based on those 2 tables (normal design patterns, so I use SQL visuals).
I've heard about hooks, like before_sev, but as mentioned, there are issues of saving or updating other objects in before_save
callback.
So, I'm thinking how to override the way to protect tracks safely?
Any suggestions are welcome.
Edit
Edit:
Select my view sql
as my_objects o *, At.value as "column1", from GENERIC_object to LEFT JOIN (SELECT at. * ON at.grereic_object_id = o.id and at.name = "param1")
This led to a "reconstruction" object from my generic table and some columns from the second table:
o.col1, o.col2, ..., but Parama 1
If there are many criteria in my object, then I will have to join again in another table, like
LEFT JOIN (SELECT at2. * FROM Another_table at2 at2.generic_object_id = o.id and at2.name = "param2")
And then, I get this object:
o Col1, O.col2, ..., at.param1, at2.param2
It seems that rare (weird ?: P), but this pattern is my impediment .... : (
From my experience, I rarely need to find such a requirement. I am overriding general methods, and I do not recommend it because the other code depends on the basic method. There is a better solution to your problem.
However, if you actually do , You can provide it via Ruby's alias_method
, or alias_method_chain
.
square fu
Comments
Post a Comment