Navigation

ADS specializes in using Ruby on Rails to build advanced, scalable, database-backed web sites for organizations of all sizes. Find out more at our website.

Atlantic Dominion Solutions

The first half of 2008 has seen a great number of happenings in the Ruby and Rails worlds. Here are the top ten for the first half of 2008.

  • June 23, 2008 - Rails scales - LinkedIn serves 1 billion pages using Rails
  • June 1, 2008 - Rails 2.1 is released
  • May 31, 2008 - Ruby 1.8.7 is released
  • May 30, 2008 - Joel Spolsky keynotes RailsConf 2008
  • May 30, 2008 - FiveRuns released TuneUp to help with Rails performance optimization
  • May 27, 2008 - JRuby 1.1.2 is released, and runs Rails 2.1 like a champ
  • April 13, 2008 - Phusion Passenger (mod_rails) is released
  • April 11, 2008 - Rails core moves to Github, prompting many to move with them
  • April 2, 2008 - Morph Labs makes Rails deployments to EC2 a cinch
  • January 1, 2008 - Thin comes on the scene as an alternative to Mongrel

See something I missed? Drop us a comment below.

Share this post

We purchase all of our domain names on GoDaddy.com and host our DNS there as well. Our main domain, techcfl.com, had been hosted along with our corporate site on FatCow, when our site was written in PHP. We converted it to Rails some time ago along with giving it a major facelift. We also use Google Apps for email, team calendar, and team docs.

At RailsConf 2008 we partnered with Morph Labs (announcement coming soon), a “complete and fully managed hosting environment for Web applications.” Mor.ph’s hosting platform uses Amazon EC2, and your application can be easily scaled with a click of a button. Since partnering, we have moved our main site, the acts_as_conference site, and the Rails For All sites there. In doing so, we had to update our DNS, and during that process, we managed to take our email down for an entire week. So, after much troubleshooting, here’s the skinny on setting it all up.

Google Apps

If you are hosting email on Google Apps (for your domain) already, there is nothing more you need to do.

Mor.ph

When you sign up with Mor.ph and create a paid AppSpace Subscription, you have access to a domain redirection feature. To use it, you add each domain you want the site to answer to. Here’s how ours is set up:

  • *.techcfl.com
  • techcfl.com

This ensures that our site responds whether or not you use the “www” in the address. Personally I hate it when web sites crap out if you don’t add the “www,” so make sure yours doesn’t do that. Once you have that ready to go, stop and start your subscription.

GoDaddy

The GoDaddy configuration was the one that took the longest to figure out. After much ado (and perhaps a good dose of ignorance and refusal to call for support), I figured out that when setting the name servers to use, if you are going to use the GoDaddy DNS servers, but host your site elsewhere, you need to select the default parked nameservers. Next, create an ‘A’ record for your root domain, ‘techcfl.com’ in our case, and give it an IP of a Morph load balancer: 72.26.105.226. After that, create a CNAME record as follows:

Alias: www
Host name: yourapp.morphexchange.com
TTL: 1 hour

Substitute ‘yourapp’ with the Morph domain you selected when setting up your AppSpace. You can find it on the subscription settings page of your Morph subscription. In our case, we named ours ‘techcfl,’ so the host name we use is: ‘techcfl.morphexchange.com’.

Once you have those records set up, you want to configure you MX (mail server) records to use Google Apps if you haven’t already. Google has the skinny on that.

Ready to Roll

Once DNS propogates you should be ready to go.

Share this post

I came across a great article on LinkedIn’s use of Ruby on Rails to serve 1 billion (yes with a ‘b’) page views per month for a Facebook application. The solution is simple: application architecture and appropriate hardware. My favorite line in the article is this: “Jim Meyer, manager of LED says that Rails scales like any other web application: ‘That is to say you need to take into account all the components from the moment the request is received at the load balancer all the way down and all the way back again.’”

Share this post

Ruby on Rails 2.1 Released

By: Robert Dempsey | Tags:

Right before the end of RailsConf 2008 Ruby on Rails 2.1 is released. New features include:

  • Time zones
  • Dirty tracking
  • Gem dependencies
  • UTC-based migrations
  • Better caching (ala memcache)

If you’ve been working with edge rails (which you all have haven’t you?) then you’ll be ready for the update. Either way, the official page has additional information on each new feature as well as links to Railscasts for visual explanations. As usual for all the goodness simply:

sudo gem install rails
Share this post

Have you ever wanted to generate documentation for your rails application quick and easy? I have recently come across a helpful rake task to help do just that. First lets add a comment to the User class to view it later in the documentation.
 

#This the User class that saves the customers login info to the site.
 
class User < ActiveRecord::Base
  # associations
  has_and_belongs_to_many :roles

Then go to console and use the rake task

rake doc:app

It generates all the html and the stats

Generating HTML...
 
Files:   448
Classes: 298
Modules: 154
Methods: 1340
Elapsed: 45.815s

Your documentation is generated in the doc/app folder with the comments that you added to the User class.

Rails application documentation

 

Share this post

Validations with attachment_fu

By: Damien McKenna | Tags:

For a project we’ve worked on recently we were using attachment_fu to handle file uploads in a series of models in part because of how easy it makes automatic thumbnail generation. As per normal practices we had certain fields, e.g. a “title” field, set to be both required and unique, but we started getting all these errors related to the title field being missing any time we’d create a new record and upload a file.

After much fiddling around with the code it finally dawned upon us - attachment_fu’s amazing abilities create partially empty records to store thumbnails, which will obviously trip up the validators. You see, when attachment_fu creates the requested thumbnails it creates additional records in the same model and uses the parent_id to link the thumbnail(s) to the master record (the one corresponding to the original upload); however it doesn’t automatically fill in the other fields as that would be too complicated to automate, so any fields other than those attachment_fu itself uses will be blank.

The way around this unanticipated feature is to restrict the validations to only records that have a blank parent_id record, i.e. only the master records, e.g.:

validates_presence_of :title, :unless => :parent_id?
validates_uniqueness_of :title, :unless => :parent_id?

Also, bearing in mind how attachment_fu handles automatically generated thumbnails it is strongly advised to keep models with attachments highly normalized (to not have many additional fields in these models not directly used by attachment_fu), otherwise you’ll end up with a large amount of waste, which can only slow down queries.

Share this post

I was getting a little fed up touching every single directory that was empty after I created a new Rails app and than pushing it to a git repo and having it not include the empty directories. So, I created a short quick script to help me out. I didn’t test it more than a couple times, but it seems to do the job. Anyway, here it is:

def touch_gitignore(path = '.')
  Dir[File.join(File.expand_path(path), '**')].each do |file|
    if File.directory?(file)
      touch_gitignore(file)
      if Dir[File.join(file, '*')].empty?
        `touch #{File.join(file, '.gitignore')}`
        puts 'touched: ' + file
      end
    end
  end  
end
 
ARGV.first ? touch_gitignore(ARGV.first) : touch_gitignore

Yes, I’m sure it can be improved. As I said, it was quick and dirty, out of frustration even.

As an example how to run it, if I named the file I pasted the code from above into ‘gitignore.rb’ then it would be something like this:

chris$ rails test
chris$ ruby gitignore.rb test

If you found this useful, how about a recommendation on working with rails?

Share this post

There is no spoon Is there some magic in a version number that I don’t know about? There must be, since so many applications use version numbers. I was thinking about this as I was adding tickets to the project from which What’s up in Ruby sprang, and mindlessly creating versions and putting tickets under each.

What constitutes a version? Is it a certain number of bug fixes or features? Perhaps a combination of both?

It struck me that in the web development world we don’t put version numbers on our apps, at least not externally. Last week we offered this set of features, and this week we have these new features. Great! But mommy always said it is good to have goals, so what are we to do?

First, stop labeling anything “beta” or “alpha” or “version 1.” There’s either something out there, or there isn’t. It might be available to a select few, but it’s out there.

Second, implement scrum. Put all of your tickets into a backlog and prioritize them. Plan what you will do for a sprint (10 working business days for us), do it, and then deploy it. At the end of that sprint you should have potentially shippable product. If you need more time extend the sprint. Be flexible with what a sprint means to you, as long as it isn’t longer than a month.

Don’t make your users wait for new features. If they work, put them out there. Get feedback quickly and respond accordingly. Software is continuously evolving. Let that evolution happen incrementally rather that in giant leaps. Involve your users in the process and you will reap the reward: happy users.

Share this post

TechCrunch posted a rumor yesterday that Twitter was going to ditch Rails for PHP or something else. This is not true. Evan Williams tweeted that this was indeed false:

“FWIW: Twitter currently has no plans to abandon RoR. Lots of our code is not in RoR, already, though. Maybe that’s why people are confused.”

I loved David’s response to the scaling argument in a recent eWeek article:

“This is known as the ‘Last Stance’ defense. When you have nothing of left of substance to argue with, you draw the ‘But does it scale?’ card. This is on page one of the Fear, Uncertainty and Doubt playbook.”

Wikipedia defines scalability as, “ability to either handle growing amounts of work in a graceful manner, or to be readily enlarged.” We can do that with Ruby and Rails, just as you can do that with many other programming languages and frameworks. People seem to forget that scalability is not simply a matter of code but the architecture of the application and the infrastructure the app is sitting on. If you design an application without growth in mind you’ll have issues, hands down. If you host your application on shared hosting and don’t give it the resources it needs you’re going to have issues.

“Can Rails scale?” is the wrong question to be asking. The right question is “how do we scale properly?”

Share this post

While normally an OSX and TextMate user, of late I’ve had need to borrow laptop running Ubuntu 8.04, so obviously TextMate has been out of the question. While the machine is powerful enough to run Eclipse (thus RadRails) or NetBeans, I wanted something simple and quick. As it turns out, Ubuntu 8.04’s Gnome 2.22 comes with gedit, which has a couple of pretty simple plugins that will make use for Rails development a little easier, but it needs a tiny final push to round it off.

First off, pop open the gedit preferences (the Edit menu, then Preferences). For programming basics you’ll want to turn on Display line numbers on the first preferences tab (under View), otherwise when you get Rails errors you won’t be able to find where they were. The next small thing worth doing is the Rails convention of using a tab width of 2 and inserting spaces instead of tabs, which you’ll find on the Editor section - oh, you’ll also want to Enable automatic indentation otherwise you’ll drive yourself crazy. One other small thing I do here is on the Fonts & Colors section I select the Oblivion color scheme, I find the darker background with the colored text to be easier on the eyes.

The fun really begins when you go to the Plugins tab, you’ll want to activate the File Browser Pane, Indent Lines, Snippets and Tag List plugins, but for good measure I also activated Change Case, Insert Date/Time, Modelines, Sort and Spell Checker, though you can skip those if you want.

At this point you’ll be able to browse through the file pane, find your project, then double-click on the main directory to turn the file pane’s focus on just your project, making it behave kinda like TextMate. You’ll also get syntax highlighting on all .rb files, which is all controllers and models.

However, there’s still something missing - no syntax highlighting on rake, ERb or RJS files - lets fix that. The rather simple fix involves tweaking some core Gnome files in the /usr/share/gtksourceview-2.0/language-specs directory to add detection for these extra files. So, in order to do this, pop into terminal and run the following commands:

sudo nano /usr/share/gtksourceview-2.0/language-specs/ruby.lang

Once the editor shows up, after completing the usual sudo login process, go down to the line that says:

<property name="globs">*.rb</property>

and change it to:

<property name="globs">*.rb;*.rake;*.rjs</property>

Next off:

sudo nano /usr/share/gtksourceview-2.0/language-specs/html.lang

Once again, search for the line that says:

<property name="globs">*..html;*.htm</property>

and change it to:

<property name="globs">*.html;*.htm;*.erb;*.rhtml</property>

And that’s all there is to it. Enjoy.

Share this post