Ruby on Rails Wednesday, July 1, 2015



On Tuesday, June 30, 2015 at 4:46:40 PM UTC+1, Federicko wrote:

Yes but I also call those method from the Class method rank and it needs to save.

This is always my dilemma, just exactly what or how much code should go into controller and model?
Like in my example, before when I had everything in the controller, people suggested that I put that code in the model.
So I did. But now, people are suggesting I take some code back out to the controller.

So exactly which part should go into the controller and which part belongs to the model?

Having said that, I do agree the self.save should be in the controller but this will break my self.rank Class method. Arrrgh!


To be completely honest, it's almost worth doing it the wrong way - until you've done it wrong (and suffered the eventual consequences) it probably does sounds like a conflicting  bunch of edicts handed down from on high. Unfortunately it sometimes takes a while for the wrongness to become apparent, and it's not always easy to spot what is hard because you're just new to it and it's normal versus what you've made hard for yourself from a poor design decision,

I think I'm basically saying that this will come with experience and don't sweat it too much to begin with. Breaking up the rank method so that the save is separate from the actual modification sounds like a bad idea though (as Colin has said)

Fred

--
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+unsubscribe@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/d4c13e64-ac3b-4007-a7e3-f13b397a2d55%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment