Posts Tagged ‘Rails’

Rails Time Extension Edge Case

Sunday, January 31st, 2010

I love the extensions that Rails has for the Ruby Time object (see ActiveSupport::CoreExtensions::Integer::Time) – you can do calculations like Time.now + 1.month, (4.months + 5.years).from_now, and other cool things.

In my last post, I mentioned working with an application that uses a subscription service. One of the things I want to do is send the subscriber an e-mail when the current subscription is about to expire. (I am not comfortable with the concept of auto-renewal; customers should have the right to “opt in” on the continuation of a subscription. Just personal preference.) So I set up a cron job that tests subscription expiration dates. Here’s the one that checks a month in advance:


next_month = Subscription.find(:all, :conditions => [ "subscription_expires_on = ?", (Time.now + 1.month).to_s.split()[0] ])

With a test case subscription expiring on Feb 28, e-mail went out correctly on Jan 28. And also on Jan 29, Jan 30 and Jan 31. Ooops! My reminder has turned into nagware. What I really want is:


next_month = Subscription.find(:all, :conditions => [ "subscription_expires_on = ?", (Time.now + 30.days).to_s.split()[0] ])

Live and learn.

Ouch. Tricky Rails Multiparameter Bug In Attribute Writers

Thursday, January 28th, 2010

I’m building a web site with a subscription-based payment system using ActiveMerchant. The first rule is, don’t put any user financial information into your local database, just pass the user input to your payment system… Continue reading

Multiple Rails Apps Under Passenger

Wednesday, December 30th, 2009

My development server is on a home LAN behind a firewall, and I don’t want to make it a DNS sub-domain. I have directed my router to issue fixed IP addresses through DHCP, so I… Continue reading

Rails and PHP under Ubuntu Apache

Tuesday, December 15th, 2009

I have Ubuntu 9.10 (aka Karmic Koala) running on my laptop. It’s rapidly becoming my portable development machine, so I set up the Rails environment right away. I have decided to add PHP to the… Continue reading | 2 Comments

Rewind Ruby 1.9.1 (or “Put The Candle Back”)

Wednesday, October 21st, 2009

I updated all the gems for my current Rails development project that is using Ruby 1.9.1. This also included an upgrade to Phusion Passenger 2.2.5. Then I upgraded to Ruby 1.9.1-p243, which promptly crashed… Continue reading

Compass, SASS, HAML

Friday, September 25th, 2009

I’m working on a project that is using the latest Rails markup buzz, namely Compass, SASS and HAML, so it’s time to begin the learning process. Part of that effort will be… Continue reading

Integrating OpenID with Authlogic

Thursday, September 24th, 2009

I won’t take any credit here. If you want to do this, jump right over to the Ryan Bates Railscast Number 170. He totally nails it – just follow along and adjust for the… Continue reading

HAML and Apache Encodings

Wednesday, September 23rd, 2009

I’m playing around a bit with the HAML gem. It broke my Apache / Passenger server immediately. The original error message looked something like:

/!\ FAILSAFE /!\ 2009-05-01 10:05:18 -1000
Status… Continue reading

Wordpress Under Rails

Friday, September 11th, 2009

There have been occasional discussions about integrating a Wordpress CMS into a Rails application. One approach is to simply do a Wordpress install under RAILS_ROOT/public/blog. That’s pretty straightforward:

cd RAILS_ROOT/public
mkdir blog… Continue reading

Changing IDEs

Saturday, September 5th, 2009

I have been bouncing between the RadRails and NetBeans IDEs for quite some time now. I like them both a lot, but I have not been able to make RadRails Test::Unit work 100%… Continue reading