Web Page Templates Icons, Clipart, Logos


Hot Topics

Post Archive


Aug 04, 2009 12:48 AM EDT

Rails Select Helper

Ruby on Rails has a bunch of built in tools to make it easy to create HTML form elements. In fact, there are so many different ones that it’s sometimes confusing to know which one to use.

Here is an example of how to build a static drop down box with the display text and the value:

Select helper:
<%= select( "controller-name", "column", { "Tools" => "T", "Reference Resources" => "Resources"}) %>

Replace controller-name with the Rails controller that you’re going to use, “column” would be the database column where you plan to store the data, and the info between the {} is the options list. For example, { “Tools” => “T” } creates: <option value=”T”>Tools</option>

Of course, you can pass in a collection or array that was generated from a database query so that the option list is dynamic.

Darren ruby on rails | helper
Aug 04, 2009 12:41 AM EDT

Install/Upgrade to Rails 2.0.2 with Eclipse, Aptana RadRails, and Subclipse

If you’re getting started with Ruby on Rails, one of the better platforms to program in is Eclipse largely due to RadRails and the SVN plugin called Subclipse. Eclipse and the community versions of the plugins are free, so it’s definitely worth taking a look at.

This article is assuming that you have a working (but possibly outdated) version of Rails installed.
If not, and you’re running on Windows, I recommend searching for the InstantRails package and installing that first.
If you’re running Mac or Linux, you’ll need to install/upgrade Ruby to the latest version and then you can proceed with the following gem commands.

To Upgrade Rails:
gem update –system
gem update
gem update rails
gem cleanup

If you run into errors (possibly when you try and add your first rails project) try:
gem uninstall rails
gem install rails
gem cleanup


Go to www.eclipse.org and find the latest version to download. The page is currently at:

Download the “Platform Runtime Binary (About 40mb)” for your Operating System.
Unzip this folder to whereever you want the install files of Eclipse to be.
Open the folder and find the Eclipse executable, and make a shortcut of it.
Move this shortcut into your start menu, desktop, or whatever you use to get to your programs.

Aptana Plugin:

Go to: www.aptana.com
Click on “get it now” for the community edition.
scroll to the bottom of the page and click “download” for the community edition.
click on the eclipse plugin tab
Click on download

In Eclipse: click on help, software updates, find and install.
Search for new features to install.
Click next
Click “new remote site”
Name it “Aptana”
Enter in the URL (which at the time of this writing is:
Follow the prompts, and select to download “Aptana” when it asks for it.

Subversion Plugin (called Subclipse):

Click on help, software updates, find and install.
Search for new features to install
Click next, then “new remote site”
Name it “Subclipse”
Enter in the URL found on the Subclipse website. Currently it is:

Follow the prompts, but uncheck the integration box because you don’t have those plugins installed.

Click Install All and Restart Eclipse when it asks you.

Aptana Rad Rails:

Open Eclipse
On the Aptana Home Page (must have Aptana installed first), at the bottom of the Languages section, there’s a link to install Aptana RadRails.
Uncheck the Ruby Mylyn Connector Feature.
Follow the prompts, install all, reboot Eclipse when it asks you.

Show SVN Repository:

In Eclipse, click on Window, Show View, Other.
Open up, SVN folder, click on SVN Repository, Click OK.

Add Rails and Rake Paths to Eclipse:

Click window, preferences, click on plus sign next to Rails, click on Configuration. Browse to your rails files.
On my Windows computer, (using the Instant Rails package), the paths were at:


Of course, this totally depends on where you installed Ruby.

Click Apply to save them.

Other Eclipse Configuration Options:

Click window, preferences.
Click on Team, SVN
Check “Select unversioned resources on commit”
Click on Apply.

In the preferences window, click on “Team”, “Ignored Resources”, Add Pattern.
Add “.project” and “.log”. If your computer saves that annoying Thumbs.db file, you might want to ignore that one too.

Good luck, and I hope this was useful to you.

Darren ruby on rails | install | eclipse | aptana radrails | subclipse
Aug 03, 2009 08:30 PM EDT

Ruby on Rails vs. PHP

I’m often surprised by the number of people that still have not heard of Ruby on Rails.

In case you haven’t heard of Rails, it’s a framework built upon the Ruby programming language. Ruby is completely object-oriented and suitable for many platforms and purposes. It can be run on all the major operating systems, and comes preinstalled on most modern flavors of Linux. Rails is a framework that makes developing web applications in Ruby take less time once you get past its learning curve.

To date, I’ve programmed in several languages. I wrote a web spider in Java, built a very popular tech support portal in ASP (in the top 3000 of Alexa’s ranking), have written countless export and database administration scripts in Perl, and have written a lot of applications in PHP such as a point of sale system, photography gallery, online appointment system, employee management system, file management system, and numerous other websites over the last 9 years.

I’ve felt that PHP has been somewhat stagnate for the past couple of years. Sure, there is version 5 that does a little more with objects and classes, but my impression is that the majority of PHP sites still run on version 4, which was released in May of 2000 even though version 5 came out in July of 2004. No doubt, PHP has been adding support for various extensions, and they’ve added additional functionality in their many sub-releases, but it’s essentially the same as it was 7 years ago.

In the first draft of this document, I stated that PHP replaced Perl, and Ruby on Rails will eventually replace PHP. Technically, that’s incorrect. PHP hasn’t replaced Perl. Rather, I believe that the developers of PHP based a lot of their functionality on Perl, but changed a few things based on what they intended to be a better system for web development. This is only my opinion, so please take that with a grain of salt as my experience developing web applications in Perl is limited.

What I can tell you with certainty is that the developers of Ruby on Rails did their homework. They’ve taken a look at all of the existing web development platforms such as Java, PHP, Perl, ASP, ASP.NET, Coldfusion, Python, etc and have a really good idea of the things web developers of these platforms had to do over and over again such as creating forms or writing dynamic database queries with optional fields in the where clause, etc. Either through personal experience or by viewing other’s code, I’m not sure, but they also knew that most ASP/PHP style sites with embedded code within HTML causes a lot of headaches on larger sites because it’s a lot harder to maintain and test effectively.

From there, they created a framework on top of the Ruby language that forces code to be separated into 3 distinct areas: The models contain database info, the controllers contain application logic, and the views contain the html templates. This makes applications more structured and easier to maintain. They also created a set of libraries that make other aspects of web development easier to deal with. ActiveRecord does a really good job of abstracting database queries. Not only does this make creating queries easier, but it makes it so the application will work for a number of different database servers without adding a bunch of kludges for each database server. There is also a feature called routes which reduces the need for GET variables in a URL string. Instead, URLs follow folder style syntax, which has been claimed in many places to be more search engine friendly.

Ruby on Rails has caused a stir in the web development community, and many businesses are moving from PHP development to Ruby on Rails development. Why? Because once you know Ruby on Rails, you can program an application faster than PHP.

In response, the PHP community is trying to catch up, but they have a long way to go, and in my opinion, they’re going to fall on their face. They aren’t unified. They aren’t creating 1 framework to rival RoR or the other main platforms such as ASP.NET or Java. I did a couple of searches and found over 40 different frameworks for PHP.

With over 40 to choose from, how can a person decide on the right one? There’s definitely a learning curve involved, so who has the time to learn 40 different frameworks? How many people are getting turned down for jobs because they know PHP, but not the right framework that the business is using? How many of these frameworks are going to still be supported in 2 or more years? The worst part of it is that many of the PHP frameworks (CakePHP comes to mind) openly claim to be a Rails clone. Why use a clone when you can use the real thing?

“United we stand, Divided we fall”.

Ruby on Rails is united. There is one framework to learn and enhance. PHP is divided with over 40 frameworks.

I still program in PHP for legacy sites, but new sites are being done in Ruby on Rails.

Ruby on Rails is not all fluffy clouds, girls fanning you with giant leaves, or whatever your personal paradise is, however.

It’s a huge pain to get the server set up just right, and overall, it isn’t as fast as raw PHP (or raw Ruby for that matter). Typically, the lower level your code is, the faster it is because it doesn’t have to compute as much. Rails has several layers of code sitting between your own code and the processor. It also has a pretty steep learning curve unless you’ve already programmed using a framework and are familiar with object oriented concepts. It’s also really new, which means that there isn’t a lot of support on the web for Rails, and many of the standard apps that people can expect to get on PHP aren’t available yet such as free forums, ecommerce sites, etc. There are a few available, but they aren’t developed as fully yet. It’s also more difficult to find a hosting company that supports Rails unless you have a dedicated server and do it yourself. They can be found, but there is only a handful so far.

Rails does provide some great features to scale a site, however. Sessions can be stored in a database, which makes it possible to have one web application span multiple servers and not worry about sessions getting lost. There’s support for caching at a page level and at a partial level (a partial in Rails is like an include or require in PHP). Currently, the best server setup uses a combination of Apache and Mongrel, a single-threaded web server designed to handle Rails applications. Apache’s proxy load balancer makes it possible to pass connections to any number of instances of Mongrel whether on the same or different servers, which makes it possible to scale a site quite easily.

Frameworks are the way to go, if you want the structure of your code to be standard and thus easier to get a new developer ramped up and productive faster. Ruby on Rails is ahead of the game and PHP is trying to catch up. Every day, people are switching from PHP development to Ruby, and unless they can come up with a unified framework to rival Rails, I believe they will lose a large percentage of their development community.

I’ve written a 2009 update to this article, also titled Ruby on Rails vs. PHP on a social network site that I wrote using Ruby on Rails.

Darren platforms | ruby on rails | php | frameworks | programming
Displaying all 3 posts

Online Information for Geeks





Resource Links