nl2br in RoR

I recently found out that line breaks are not recognized when displaying a large block of text on the view (e.g. a post body). In PHP this was handled by the nl2br method but I had no luck finding a similar function in RoR. So I did what any sane person would do, create one myself. I placed this method in our model to format a particular field but it seems a better choice to put it in a helper.

def nl2br(text)

return text.gsub(/\n/, ‘<br/>’)

end

And there you have it, your very own nl2br method. Either you just found something really useful or I just wasted 2 minutes of your time. If anyone has a better solution or if I missed a function for this let us know by dropping a comment.

Small But Terrible

I’m pretty sure most of us have been in a situation where we have been trying to fix a bug for hours and finally seeing that there had just been some tiny typo or maybe even a commented line of code. I’ve been through a lot of those experiences before, especially when I was still learning to code, and most of the time, I just breathe out a huge sigh of relied or just plainly laugh at myself.

Reminiscing about those ‘good old days’ could be fun too. Here’s some of those ‘what the hell/oh come on/I knew it was just a simple mistake!’ scenarios that I have experienced or just know of:

These are just some of the mistakes that we can encounter while coding and minimizing the chances of these happening can help in coding a lot faster and having more time dealing with bugs that matter.

January 2008 PhRUG Meet-up

A PhRUG meet-up was held on Jan 16, 2008 at Ateneo de Manila University sponsored by Admoo Labs. 30 people attended the event. I gave a presentation on ‘Website Development with Ruby on Rails’. Greg Moreno talked about RSpec.You can download a copy of my presentation here. Pictures are here.

Hello World.

Hello, world. We are Admoo Labs!

We’re a group of four young men trying to start something big while starting small and this blog is where you’ll find our “story”. My colleagues, Topher, Gerald, and Eumir, will occasionally drop by here too and share their thoughts on web development, startups, business, and life in general.

Stay tuned, folks. I may just be being my usual optimistic self, but I think this is the start of something wonderful. ;-)