Re: [Rails] Re: call a controller method from model
On Thu, Aug 25, 2011 at 2:20 AM, Angelo Cordova <acordinz@gmail.com> wrote:
Well, the example I used is a little simple for what I really need.
I have 4 models
Model A, Model B, Model C, and Model D
Everytime I update Model C, I have to update Model B
Everytime I update Model D, I have to update Model B
Everytime I update Model B, I have to update Model A, but this update
depends on "which" model has updated Model B. if Model C has updated
Model B I have to make some changes in Model A. But if Model D has
updated Model B I have to make differnts changes in Model A.
I think the simplest way to do this is to have an after_save callback on ModelC and ModelD.
Just call the method that will update ModelB and ModelA on the callbacks.
My problem is that I don't know how can I recognize which model has
updated Model B to "switch" between actions to update Model A
On Aug 24, 2:50 pm, Tim Shaffer <timshaf...@me.com> wrote:
> This is a bad idea. Models shouldn't know about controllers at all.
>
> What does the controller action do? Perhaps you can just do that in a method
> on a model.
--
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.
-------------------------------------------------------------
visit my blog at http://jimlabs.heroku.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