Michael Pavling wrote: > On 2 August 2010 15:34, Dave Aronson <[email protected]> > wrote: >> �...@activated_msg = 'You need to activate this one' >> end �# you did mean end for the 2nd else above, yes? > > I know that you and Marnen have covered this, so I won't go over it > too much, but I would add my voice to the "it should NOT be in the > controller" camp. I may reuse the same views from several controller > actions, and I don't want to have to duplicate the variable-setting in > lots of places.
I, too, have been giving more consideration to unnecessarily using instance variables. A few years ago, I used them all the time, but the more I use partials, the more I prefer to pass variables in :locals. > > The "I don't want view text in my controllers" has already been covered. > > I also don't see the value in setting instance variables to store > values that are accessible on the model that's being passed to the > view. +1 >> (BTW, note the single quotes; I haven't verified it myself, but heard >> that they are at least marginally faster for constant strings (i.e., >> where you *can* use them), since the system won't even *try* to look >> for vars that need to be interpolated. �Makes sense to me.) > > They are, to all reports, marginally faster, but I still use double > quotes everywhere for ease and consistency . It strikes me as > premature optimisation to default to single quotes for the minuscule > time advantage (and I rarely set strings to variables anyway; > generally following the "extract variable" refactoring pattern instead > and call a method to return them - even slower! But easier to maintain > ;-) This is likely one of those "matter of personal preference" things. I make it a point to use double quotes *only* when I'm interpolating. It started out as "premature optimization", but I also find that when scanning code, I can automatically ignore one or the other depending on what I'm scanning for. If I'm looking for a particular piece of interpolation, I can ignore everything surrounded by single quotes. [ Or, I could just use Find ;) ]. And I suppose one could make the argument that using single quotes except when you need double will save you from having to press the SHIFT key, though I wouldn't be one of them. I used to work with a guy (Delphi developers at the time) who never capitalized anything he didn't have to. I once asked him why and he said it was because he didn't want to waste the keystroke of pressing SHIFT. Different (?:key)?strokes for different folks, I guess. Peace, Phillip -- Posted via http://www.ruby-forum.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 [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

