How To Fix ActiveRecord::ConnectionTimeoutError with Sinatra
If you get this error message ActiveRecord::ConnectionTimeoutError could not obtain a database connection within 5.000 seconds (waited 5.001 seconds) Try closing the connection after each request using "after" in Sintara. # app.rb after { A...
Written by Sean Behan on 11/09/2013
Aliasing Attributes in Ruby on Rails
Alias an attribute with alias_attribute method. The first argument is the name for the new attribute, while the second argument is to identify the attribute that is already defined. class User < ActiveRecord::Base alias_attribute :username, :login ...
Written by Sean Behan on 06/17/2012
Rails Find All by Birthday: How to Find Upcoming Birthdays with ActiveRecord
There are a few ways to solve this problem. However, I think the easiest is to cache the day of the year that the user is born on as an integer. If stored alongside the timestamp we can quickly get a list but properly handle the full birthday elsewhere, s...
Written by Sean Behan on 06/17/2012