DaveSouth.org

Email RSS Twitter Delicious

Rails subdomains, CNAMEs, and crzy.me

Setting up a Rails development environment to handle subdomains and custom domains is tricky. There are lots of suggestions from editing your /etc/hosts file, custom rack applications to handle CNAMEs, dnsmasq for wildcard domains, and more. All of them are compromises and often caused more problems than they solved. However, there is a decent solution to the problem. (Continued…)

Stop guard from automatically running all tests

Ruby guard is an excellent replacement for ZenTest’s autotest. Originally guard would not run all tests unless you told it to. I liked this behavior because it meant running just the test I’m working on until I’m ready to run the whole suite. (Continued…)

How to set up dnsmasq on Snow Leopard for local wildcard domains

We had a working solution to use wildcard domains on the localhost. Using a proxy.pac file and a tiny rack application we could pass any domain into the development environment. It was working great, until we tried switching to Rails3 beta. Whenever we specified a non-standard local domain, the Rails router would strip the query string off the URL. This method is out-of-date. For a far better way please read Rails subdomains, CNAMEs, and crzy.me (Continued…)

Eliminate subdomains and CNAMEs in Rails development

Having two methods of identifying the same edition on a CMS — subdomains and CNAMEs — is painful. Yet many websites have advocated this approach. Every request to the application requires multiple checks on the domain to correctly identify the edition. I believe this process developed from the difficulties of dealing with subdomains and domains in the development environment. Recently we found the answer that simplifies the whole system. This method is out-of-date. For a far better way please read Rails subdomains, CNAMEs, and crzy.me (Continued…)

Rack CustomDomain converts CNAME hosts to subdomains

When we created our CMS we used tried-and-true subdomains to separate editions. SubdomainFu handled the logic of separating editions and it was easy — until we added custom domains. The standard method is to point — via CNAME — the custom domain (www.davesouth.org) to the subdomain (davesouth.example.com). Unfortunately the rails app can’t use SubdomainFu routing. This method is out-of-date. For a far better way please read Rails subdomains, CNAMEs, and crzy.me (Continued…)

Subdomains and local development using proxy.pac

The NeolithicCMS we are writing separates editions by using subdomains. It works great in production. A single entry of *.neotrib.com in the DNS points all subdomains to the same server. But for local development we have to manually edit the /etc/hosts file for each subdomain. After adding a few editions it becomes a royal pain. Short of installing a DNS server, we needed a better solution. This method is out-of-date. For a far better way please read Rails subdomains, CNAMEs, and crzy.me (Continued…)

Speed up “Find in Project” in TextMate

TextMate’s very useful “Find in Project” is super slow for any decent Ruby on Rails application. The problem turns out to be very simple. TextMate searches the entire project tree including the tmp and log directories. It takes a lot of time to dig through those directories — especially the log directory which can quickly become many megabytes in size. Not only that, rarely do we want “Find in Project” to return results from these directories. The solution is simple. (Continued…)

Make URL friendly filenames in paperclip attachments

We use Thoughtbot’s Paperclip gem to attach images and other media to our Ruby on Rails models. When we save documents to a model object, we wanted to make sure the filenames were URL friendly — lowercase with only letters, numbers or hyphens. Paperclip’s processing chain makes it easy to insert this behavior before saving the file or running it through the thumbnail re-sizer. (Continued…)

Our cover is blown

For several years, Loy and I have worked under the company name of Apped Design. It was a cover name Loy came up with when we attended the first Mountain West Ruby Conference in 2007. The Neotribune was on the back burner and we were working on a couple of Ruby on Rails projects. We decided that it would be easier to go as independent consultants than try to explain a long, convoluted startup story no would be interested in anyway. (Continued…)

Test Spec and the Double-R

Last year we did a project with substantial business logic requirements. The Rails testing framework saved us. We could create tests for all the different uses of the system and ensure that these rules were always followed. As wonderful as it was, there was a bitter aspect to Rails testing — fixtures. (Continued…)

Install Ruby on Rails using MacPorts

There are several ways to set up a system for Ruby on Rails development. Leopard comes pre-installed with Ruby and Rails and is perfectly fine for most users. For me, however, I kept running into troubles. Trying to do a free standing install of graphic libraries (FreeImage or ImageMagick) proved too painful. I switched back to using MacPorts. (Continued…)

Multiple uploads using Rails, SWFUpload and AttachmentFu

UPDATE: August 27, 2010. The SWFUpload.org website is clearly hacked and displaying spam entries all down the home page. The last beta was months ago with no apparent progress since then. Some users report being unable to upload files any more. I cannot recommend the project any more. We are evaluating uploadify and plupload. Also, we no longer use AttachmentFu for new projects. I highly recommend Carrierwave or Paperclip. (Continued…)