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

Rails and PHP under Ubuntu Apache

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 development mix, so I began to install all the PHP stuff using Ubuntu’s built-in Synaptic Package Manager found under System -> Administration. That worked fine, but oddly enough, the package manager uninstalls the Phusion Passenger module for Apache2. Huh! Here’s the executive summary to get Rails and PHP to coexist on a Ubuntu Apache server: Install all the PHP goodies Install the Passenger gem Run passenger-install-apache2-module to compile the Passenger module Add the Passenger LoadModule… Read More

Continue Reading

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

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 Passenger when I did a session request through Authlogic 2.1.2. Ouch. So, I reinstalled Ruby 1.9.1-p129, and all is well again. Oddly enough, there is no uninstall switch in the Ruby-for-Linux tar ball Makefile. The default install location is /usr/local, so I can keep the Fedora 8 version of Ruby 1.8.6 (via the RPM package system) intact, but I wasn’t sure what would happen if I simply re-installed the older Ruby 1.9.1 version under /usr/local. As… Read More

Continue Reading

Compass, SASS, HAML

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 to convert my personal Rails project over to Compass et. al. I found that the best approach seems to be to install all the required gems manually before doing anything else. That is: Installing HAML also installs SASS, which is pretty convenient. Then install the basic compass gem. Compass supports a few standard stylesheet frameworks: 960gs, blueprint and YUI. I’m using 960. For Rails integration, you can either build a new Rails project, or you can choose to… Read More

Continue Reading