Even though I've been "playing" with RoR since before 1.0, I've never
got a good grasp on where you put code!

Code or helper method placed in helpers can only be called from views,
if I'm not mistaken.

Code that is specific to a model or controller is also a no-brainer -
but what about code that you want to share in different models/
controllers.

What if I have a function unformatPhone that I want to call in a
model's before_save event - where to I stick it so that it can be
called by all models and maybe even from a view?

Is my only choice in the application_controller? Is that a good
choice?

The unformatPhone example may be trivial since it is only a regexp
replace, but what if it is something more complex. I looked around for
something that would set the case of proper names and found something
on github (http://github.com/tenderlove/namecase/tree/master) which is
a class. Where do I stick that?

If anyone can point me to a good tutorial on where you put code, I'd
be thankful.


--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to