[Rails] Re: Customizing Model Data -- Inside Model or View or Helper?

2009-01-31 Thread Hassan Schroeder
On Sat, Jan 31, 2009 at 10:06 AM, Randy Kramer wrote: > Off the point, but before we allow a word like commified to escape into > the wild (see usage in next post by Rob Lacey), we spell it commafied > instead--there is a slightly greater chance of guessing its intended > meaning. And even grea

[Rails] Re: Customizing Model Data -- Inside Model or View or Helper?

2009-01-31 Thread Randy Kramer
On Friday 30 January 2009 09:31 pm, ericindc wrote: > commified_name Off the point, but before we allow a word like commified to escape into the wild (see usage in next post by Rob Lacey), we spell it commafied instead--there is a slightly greater chance of guessing its intended meaning. Ran

[Rails] Re: Customizing Model Data -- Inside Model or View or Helper?

2009-01-31 Thread ericindc
Thanks for the replies, fellas. I've moved the code into my Model. Thanks again. On Jan 31, 11:33 am, Rob Lacey wrote: > Agreed its easier to test models, or at least I find it easier. I'd say > that its a fortunate side effect though, rather than a reason to test in > a certain way. Although I

[Rails] Re: Customizing Model Data -- Inside Model or View or Helper?

2009-01-31 Thread Rob Lacey
Agreed its easier to test models, or at least I find it easier. I'd say that its a fortunate side effect though, rather than a reason to test in a certain way. Although I guess if it really is too hard to test any part of your app then you're probably trying to solve the problem in the wrong w

[Rails] Re: Customizing Model Data -- Inside Model or View or Helper?

2009-01-31 Thread Phlip
> Generally I would go with whatever solution feels more natural, and > easier to manage for you. Don't get bogged down in convention if it > doesn't work for you or feels wrong. I prefer to say that like: Put the code where it's easiest to test. Models are easier to test than controllers, so

[Rails] Re: Customizing Model Data -- Inside Model or View or Helper?

2009-01-31 Thread Rob Lacey
Hi there, Ok that statement was probably a bit ambiguous. I'd use a view helper to encapsulate something that is purely view based. I'd say that commified_name isn't confined to the view, its legitimately an attribute of the model - model attributes aren't confined to database attributes. I d

[Rails] Re: Customizing Model Data -- Inside Model or View or Helper?

2009-01-31 Thread ericindc
Oops, I meant A (in the Model) is the best answer, not C. On Jan 31, 9:42 am, ericindc wrote: > Thanks for the reply. > > "I'd only really use a helper method to encapsulate repeated code in > views." > > But isn't that the case here?  I repeatedly use the commified version > of the name inside

[Rails] Re: Customizing Model Data -- Inside Model or View or Helper?

2009-01-31 Thread ericindc
Thanks for the reply. "I'd only really use a helper method to encapsulate repeated code in views." But isn't that the case here? I repeatedly use the commified version of the name inside of my views. So why wouldn't C be the best solution? Wouldn't using A break that convention? I also use th

[Rails] Re: Customizing Model Data -- Inside Model or View or Helper?

2009-01-31 Thread Rob Lacey
I would always go for A def commified_name "#{self.firstname} #{self.last_name}" end It keeps the formatting in one place, no need for an additional helper method or indeed a helper class. I'd only really use a helper method to encapsulate repeated code in views. Just suppose you wanted to s