I’ve written several helper methods to assist me throughout an application. I’m not fluent in the Ruby language, so these helper methods don’t always go perfect the first time. Usually they aren’t too complicated, though. What I’m finding is that each time I write one, I think, “I’m sure I’m not the only one who has done this.” And sure enough, I’m not. So much, in fact, that Ruby has very similar methods built right into the language. Things like strip_links and pluralize. Simple, but very handy. And perhaps most importantly, they’re time savers.
For instance, just recently I wrote a function to find all of the new line (\n) characters within the comments, and “gsub” them into line break tags. This is a simple function, obviously, but it still wasted my time because I later found out about simple_format which does that very thing. It will treat one \n as a break tag and two \n’s as a new paragraph. I know what you’re thinking, “Why aren’t you using Textile?” I don’t have an answer for that. I haven’t looked into it much, but I believe you simply pass the text to an instance of a new RedCloth object, and then convert it back using .to_html? I think I’m a little skeptical when it comes to installing plugins/gems since I often have trouble getting things of that nature to work correctly on Dreamhost. Then again, it’s often a more effective way for me to learn when something is broken. And I’m usually good at that. Anyway, the point is the Ruby language is brilliant and it really was designed for productivity.





