.

Coffee Powered

code and content

Tag Archives: Rails

Quick tip: Strip URLs before parsing!

Rather than roll my own URL regexes, I prefer to let the existing libraries do the heavy lifting. Ruby has a uri library which is fantastic for parsing (and validating) URLs.
For example, something like this might be used in a model validation:

require 'uri'

def validate_url(url)
parsed_uri = URI::parse(url)
rescue URI::InvalidURIError
errors.add :url, "Sorry, that doesn't look like a valid [...]

Mass inserting data in Rails without killing your performance

Quick tip – use anonymous blocks!

Re: Simple RoR+MySQL optimization

Powerful, easy, DRY, multi-format REST APIs

Stupid attachment_fu tricks, part 1

Jabberish: making Rails talk back

site_config – painless custom configuration for your Rails project