For when you don’t want to type a dozen times, add this to application_helper.rb:
def nbsp(n=1)
n.times.map {” ”}
end
In a view:
<%= nbsp 5 %>
replaces
addthis_url = ‘http%3A%2F%2Fwww.alandelevie.com%2F2010%2F07%2F16%2Ftrivial-rails-tip-easy-html-spaces%2F’;
addthis_title = ‘Trivial+Rails+tip%3A+easy+html+spaces’;
addthis_pub = ”;
Up until now, I’ve done nearly all of my Rails programming on Windows Vista (64 bit). The environment has been pretty good, but it’s time for a change. This was probably due a while ago, but I’ve decided to explore Linux with a dual boot of Ubuntu 10.x.
Thanks to StackOverflow and some Googling, I got [...]
A few months ago, I read a blog post by the Flickr developers on how they built an internal tool called a “feature flipper”. A feature flipper lets a site admin deploy/rollback features from a simple dashboard with a single click. Think of being able to add an on/off switch to any piece of code [...]
I’ve been working on an admin panel for a certain Rails app. One of the most common tasks to writing an admin panel is to generate a table where each column is a different attribute for your model. This is easy to do, but very tedious.
To simplify the task, I looked at metaprogramming. Metaprogramming with [...]
Eager loading in ActiveRecord is a great feature. It prevents what’s called the “n+1″ problem. From the docs (emphasis mine):
Eager loading is a way to find objects of a certain class and a number of named associations. This is one of the easiest ways of to prevent the dreaded 1+N problem in which fetching 100 [...]
Fellow Three Screen Games (the company that created FanGamb) co-founder, Robert Shedd, wrote a tutorial detailing how to safely update a database using the Facebook platform’s callback urls in a Rails app.
addthis_url = ‘http%3A%2F%2Fwww.alandelevie.com%2F2010%2F01%2F09%2Ffacebook-callback-urls-rails%2F’;
addthis_title = ‘Facebook+callback+urls+with+Rails’;
addthis_pub = ”;