Archive for May, 2007

How to: Get Started with Ruby & Rails

Ruby on Rails is a popular web application framework that automates the creation of common web applications. It’s a great choice for many developers because it allows you to program quickly and have fewer opportunities to make errors. Rails’ rise in popularity has brought a plethora of information and we’ve found the best that’s out there. Get your Rails experience started right with our picks for the best books, web resources and hosts for Ruby on Rails.

Best books

There are quite a few Ruby on Rails books out there. Here are a few to that would be good to work through, then keep on hand. These will provide the knowledge you need to get started as well as serve as handy references for later.

Ruby on Rails: Up and Running by Bruce Tate and Curt Hibbs: Ruby on Rails: Up and Running is a great reference for those just getting started in Rails. It offers an easy way to learn and will set you up with a solid foundation of knowledge. The book walks new users through the elements that are most important to understand, covering concepts from simple database applications to elaborate Ajax. Thin and simple, it serves as a quick introduction for those that want to jump in and learn Ruby on Rails quickly.

Rails Cookbook by Rob Orsini: The Rails Cookbook is great for learning because it’s a “how-to” book. Readers like it because it’s a “’Here’s how to do the things you want to do’ kind of book.” It’s aimed at programmers who are familiar with web development, but have not yet worked in Rails. It offers real-world challenges, providing solutions and a discussion of how the solution works. This allows users to learn how to adapt the challenges to their own applications. Rely on The Rails Cookbook for a straightforward approach that will help you learn faster.

Agile Web Development with Rails: Agile Web Development with Rails is an award winning book, co-authored by David Hansson, the creator of Rails. It’s been updated for Rails 1.2 in the second edition. It’s ideal for users who are just getting started learning Ruby on Rails because it doesn’t bother with overloading readers with too much detail, opting instead to offer details in the appendices if you’re interested in learning about them. Readers like this book because its format is great for getting your feet wet. You’re walked through the process of building a shopping cart and then later delve into exactly how Rails works. It’s written for all skill levels in an easy to understand language.

Best web resources

The web has a lot to offer for getting your feet wet with Ruby on Rails. Many of them provide interactive, innovative ways to learn Ruby hands on, so they’re a great option for people who learn best by just throwing themselves into something new. These resources are easily accessible, fun to use, and best of all, free.

Try Ruby!: This website offers an ingenious browser-based tutorial for the Ruby language. All you need is a web browser and 15 minutes. In this tutorial, you’ll learn Ruby by typing provided codes into a prompt screen to see how they run. Once you see how they work, the commands and concepts are explained in detail. Try Ruby points out basic concepts and common errors, helping users to lay a solid foundation for their Ruby on Rails education. Check it out for a quick, fun look at Ruby.

Four Days on Rails by John McCreesh: This guide, available in PDF, offers new users a view of the things they’ll need to do to get started in Rails development. It’s ideal for learning because it’s well organized and offers very simple tasks. This makes it easy to grasp the concepts put forth. The tutorial covers topics like how to create a scaffold code, build a to-do list application and more. As the title suggests, the document is split up into four days, but most users can work through it faster than that. Break it up into four days or hunker down for an extended session of Rails tutoring.

Ruby on Rails Cheat Sheet: When you’re just getting started, it may be hard to remember every little detail that you need to know. This cheat sheet offers a way to keep lots of useful information on hand for quick reference. The sheet offers a reference for Rails’ directory structure, pre-defined variables, reserved words, regular expression syntax and methods. The author used expert advice, including that of the Rails original developer, David Heinemeier Hansson. Keep this guide handy so you’ll have all the information you need close by.

How to get started developing

Even if you’re not ready to launch your site yet, you need a space to play around in to see how your web applications will execute in the real world. To do this, you need to find a good host that you can trust with your hard work. Check out these hosts for reasonable, reliable service.

Slicehost: Slicehost offers Rails developers a hosting solution for those looking for low cost with a quick setup. It is a great option for cheap learning. Nuby on Rails recommends Slicehost for developer education: “Spending $20/month on your own education will be worthwhile and will help you make mistakes on your own before making them on a paying client project. Slicehost would be a great environment for that kind of self-education.” For quick setup, Slicehost provides a Wiki for a 5-minute installation of Ruby on Rails. Use Slicehost for cheap and easy Rails hosting.

RailsMachine: RailsMachine has a quick setup, so it’s easy to get started and get down to work on your Rails education. They have a gem for Ruby on Rails that minimizes setup to just a few easy commands. RailsMachine is a good option for when you’re ready to launch your site, too. They offer reliable uptime, knowledgeable staff, superior support and high quality hosting. Work with RailsMachine if you’re willing to spend money on a trusted source.

TextDrive: TextDrive is the official Ruby on Rails host, which makes it another great option for Ruby on Rails education. They have knowledgeable staff and all of the latest Rails extras, so you can be sure that they will provide you with the best resources a Rails host can give you. Original Rails developer David Heinemeier Hansson supports TextDrive because with them, “you’ll always have the latest version available as GEMs, you can keep your code under Subversion (and show it off with Trac), and have your choice of PostgreSQL or MySQL for the database.” Plus, he points out, 50% of the profits from your TextDrive plan will go to supporting Rails development.

For more information on Ruby on Rails, visit the following sources:

Ruby on Rails: www.rubyonrails.org
Loud Thinking by David Heinemeier Hansson: www.loudthinking.com
Wikipedia: Ruby on Rails: http://en.wikipedia.org/wiki/Ruby_on_Rails

How to: Survive the Digg Effect (The Ultimate Guide)

Forty thousand hits in one day may sound like every webmaster’s dream for their site, but in reality it can be a nightmare. A massive influx of traffic from Digg has the power to cripple or crash your website. Are you ready to get Dugg? Here are a few tips to help you ride out the storm.

Get fair warning.

Digg Notify is a tool that informs you of the amount of diggs that your story has received. It will also let you know when your story hits the front page. Watching interest build in your story isn’t just fun: it’s crucial. If you get caught off-guard, the Digg effect can bury your site.

Get friendly with your hosting company.

Before facing Diggstruction, call your hosting company to find out what they’d do in a high traffic situation. Would they leave your site down for hours while you miss out on thousands of unique visitors? Or would they take quick action to give your site the resources it needs? If you’re not getting a warm and fuzzy feeling from your provider, shop around until you find a company that is able to fit your needs. You don’t want to get stuck with an unhelpful or unresponsive hosting company when you need help the most.

Key questions to ask your host:

Do they want notification when you’re being Dugg? Some hosts will take your site down because they suspect you’re being attacked.

Will you need a larger hosting package? Consider this: Paying $50 more per year is a lot better than being suddenly hit with $800 in overage charges. If you can afford it, go for a dedicated server rather than one that you have to share with other sites.

Can you get a free upgrade? Monetize recommends bartering. If your page is, or will be, subject to a flood of hits, try to get a free upgrade by offering to link to their service.

Design for Digg.

Even with a supportive host you will need to optimize your site for an inundation of visitors. You’ll need to deal with heavy script and large files in order to keep up.

  • Keep it simple. Don’t bog your page down with huge amounts of script. This will only slow performance. Also, keep in mind that every image, regardless of the size, accounts for an additional HTTP request that can bring you down.
  • Implement Apache tweaks. Make some changes to your Apache code to help with timeouts. HowtoForge has a list of helpful tweaks to try out on your site.
  • Create a load balancing solution. If you have multiple servers, try round robin DNS load balancing. This method uses multiple A names to send visitors to different servers. Visit Website Gear for details on how to implement this technique.
  • Don’t put all your eggs in one basket.

    Host your images and media files away from your site. Use a separate hosting company for these resources. Places like Flickr and YouTube offer great, free services for separate hosting.

    Have a simple HTML page ready.

    If you don’t want to make these design changes for everyday use, at least have an uncomplicated page ready in case of a Digg emergency. If you think your article is going to receive a flood of Diggs, create a landing page with straightforward HTML where you can redirect traffic if you start to go under.

    Get some Cache.

    Good design is key. But, if you’re getting crushed, your site will need an extra boost to stay up. Try using cached pages. It will help with site performance and may just give you the extra edge you’ll need to keep up with the traffic.

    Install the WordPress caching module.This plugin lets you serve more pages per second by caching and storing pages in a static file. Requests go through the file rather than through PHP code and the database. Johnny’s Thoughts offers a tutorial on using WP-Cache 2.0.

    Redirect to DuggMirror or Coral.

    Desperate times call for desperate measures. If your site takes a nosedive, redirect Diggers to a mirror site. You’ll miss out on getting links, but at least you’ll get readers to your article. DuggMirror makes a copy of all stories submitted to Digg. Michi Kono’s blog offers a guide to redirecting to DuggMirror. Another option is using Coral. Shoemoney offers code for the Coral tool on his site.

    Get testy.

    Make sure these changes are helpful for your site by putting it through a stress test. Tarotoast recommends using, Apache Benchmarking, to see how your site holds up. Other resources are WAPT and Web Application Stress Tool.