Rails Time Extension Edge Case

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… Read More

Continue Reading

Ouch. Tricky Rails Multiparameter Bug In Attribute Writers

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 (i.e. Pay Pal, Authorize.net, etc.). So how do you handle this information? attr_accessor to the rescue. You can have something like this: Now you can work with the users credit card number (as just one example) without commiting it to the Subscription table. But – one thing you need is the card expiration date. You can get that information from the user in a drop down menu in the view: This is a multiparameter situation,… Read More

Continue Reading

Multiple Rails Apps Under Passenger

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 can use the IP address as part of the URL. Setting up multiple Rails applications is pretty easy, but if you want to mix the Rails environments (developement / test / production / custom), you need to use <Directory> to configure each Rails app: By using <Directory> you can change the behavior of each of your Rails applications as needed, including the ability to disable Passenger for non-Rails code (such as the blog shown in… Read More

Continue Reading