Ruby on Rails in 2,057 Words

Web Languages
  • Smaller Small Medium Big Bigger
  • Default Helvetica Segoe Georgia Times

If you've been following the latest technologies and trends at all lately, you have undoubtedly encountered the phrase "Ruby on Rails" (also often referred to as "RoR" or just "Rails") and discussion about why it's the best technology in the world or whether it's just another over-hyped buzzword. Rest assured, Ruby on Rails is the real deal, and it's here to stay. Rails has definitely gained a lot of merit since its inception, and while it may or may not be the best fit for your next Web-based application, it is important that all Web developers and Web architects have at least a fundamental understanding of the features that Rails brings to the table.

Brief History of Ruby on Rails

A common misconception is that Ruby on Rails is by itself a single technology. It's not. It is important to understand that Ruby on Rails actually consists of two major technologies. The first component is called Ruby. Ruby, by itself, is "just" a programming language. Ruby was released to the general public in 1995 by its creator, Yukihiro "Matz" Matsumoto. Ruby has syntax similar to Perl and object-oriented features similar to Alan Kay's Smalltalk. Ruby is a strongly-typed (i.e., expressions such as "4" + 5 are illegal), single-pass interpreted language.

The second major component (and the cornerstone of the hype) of Ruby on Rails is Rails. Rails is a Web application framework written completely in the Ruby programming language (and hence the derived name, Ruby on Rails). A Web application framework is a set of tools and libraries that make it "easy" to create Web-based applications. The sad reality is that within most development projects, a sizeable amount of time is spent not solely on the application logic itself, but rather on a foundation and a set of reusable components for use throughout. It's these reusable artifacts that are collectively referred to as the application's framework; this is precisely where Rails can lend a helping hand. The Rails framework debuted nearly three years ago, in July of 2004. David Heinemeier Hansson, Rails' creator, actually created the Rails framework while working at 37signals on a project called Basecamp. He immediately saw the value in making the framework available to the public and released it as an open-source project for the world to take advantage of all the great things Rails has to offer.

Reduce Your Development Time

Does Rails provide any new function with respect to other technologies? Not really. However, it does allow you to accomplish the same tasks in potentially a fraction of the time. Rails offers the potential for teams to build a wide range of complex Web sites in weeks instead of months, without sacrificing quality of code. Rails promotes good programming practices, which leads to intuitive and easy-to-maintain code. Continue reading to experience the benefits of Rails.

Features and Benefits of Rails

Rails has many features that provably make a reduced development schedule and an easy-to-maintain project a reality. Some of its key benefits include these:

  • MVC framework—The Rails framework is an instance of the ever-popular MVC (Model-View-Controller) framework; it offers components to easily model your data, elegantly present it to the user, and simplify the interaction between the user and the model(s).
  • Fewer lines of code—Rails removes much of the tedious work (e.g., writing a heavy-weight data access layer or a transaction manager layer) from an application's framework and instead allows you to spend more time on your actual application logic.
  • Ruby gems—Ruby packages additional libraries in what's called a gem (e.g., Active Record, whose description is forthcoming, is a Ruby gem); this packaging system makes it easy to obtain new libraries and resolve dependencies between libraries.
  • Easy code testing—Since Rails ships with its own Web server for most platforms, you can easily write your code and immediately test it without having to go through lengthy deployment processes; Ruby also has full support for application breakpoints to aid in debugging.

Introduction to Ruby Gems

As mentioned, a Ruby gem is an additional component to the Ruby programming language. In the general sense, understanding and knowing which gems are available is what will lead you to successful projects; let the gems do the work for you! The following list offers high-level explanations of a small subset of the available Ruby gems.

Active Record

To quote the official definition, "Active Record is a Ruby gem that connects business objects and database tables to create a persistable domain model where logic and data are presented in one wrapping. It is an implementation of the object-relational mapping (ORM)." In essence, this means you no longer need to spend your valuable time creating the ORM layer. In the J2EE world, this is where you'd normally spend countless hours creating Java beans and data access objects (DAOs). Rails simply waves goodbye. Active Record shields the need for SQL constructs within your application code but does support it for times when absolutely necessary. Per the Active Record documentation, some of its major features include these:

  • Automated mapping between classes and tables, attributes and columns
    class Person < ActiveRecord::Base; end

    ...gets automatically mapped to the "person" table below...

    CREATE TABLE person (
          id int NOT NULL,
          first_name varchar(63),
          last_name varchar(63),
          PRIMARY KEY(id)
  • Associations between objects controlled by simple meta-programming macros
    class Patient < ActiveRecord::Base
          has_many :medical_records
          has_one :primary_physician
  • Inheritance hierarchies
    class Animal < ActiveRecord::Base; end
    class Pet < Animal; end
    class Cat < Pet; end
  • Transaction support on both a database and an object level
    # Database-only transaction
    Account.transaction do

    # Data and object transaction
    Account.transaction(david, mary) do
  • Logging support for Log4r and Logger,which allows you to take a step-by-step look at what the data access layer is doing
    ActiveRecord::Base.logger =
    ActiveRecord::Base.logger ="Application Log")

As you can see from just some of the examples above, Ruby on Rails abstracts a lot of the typical data access logic so that you never need to work with the raw SQL and database structures. Again, this allows you to spend more time on your business logic than on primitive (with respect to the application) components.

Action Pack

Action Pack handles both the View and Controller parts of Rails. It splits a response to a Web request into a Controller part (performing the logic) and a View part (rendering a template). This is known as an "action," which will normally create, read, update, or delete (CRUD) a Model part before choosing to either render a template or redirect to another action. Action Pack implements these actions as methods on Action Controllers and uses Action Views to implement the template rendering. Action Controllers are then responsible for handling all the actions relating to a certain part of an application. Per the Action Pack documentation, these are some of its major features:

  • Simple URL routing—Incoming URL requests get mapped to an action within an Action Controller, which is a Ruby class that has a set of public methods that handle the particular action. As an example, if Rails received a request for, Rails would hand this request to StatementController::display(54) for processing.
  • View templates—View templates are essentially the HTML to give back to browser requests (think JSP files) and are stored with the rhtml filename extension. Text within <% %> is executable Ruby code, similar to that found in Java Server Pages (JSPs).
  • Helpers for forms, dates, action links, and text
    <% text_field "post", "title", "size" => 30 %>
    <% html_date_select( %>
    <% truncate(post.title, 25) %>
  • Javascript and AJAX integration
    link_to_function "Greeting", "alert('Hello World!')"
    link_to_remote "Delete this post", :update => "posts",
                      :url => { :action => "destroy", :id =>

Action Web Service

Action Web Service implements server-side support for SOAP and XML-RPC Web service protocols. It integrates with Action Pack so that you can easily publish APIs via the Web Service Definition Language (WSDL). For more information, please visit the official Rails Action Web Service page.

Action Mailer

Almost all of today's Web applications need to communicate with its users in some fashion, so it should be easy to achieve, right? Of course! Ruby's Action Mailer allows you to either send or receive email from within your application. Here's an example snippet of how to send an email message:

def send_message(user)
  recipients user.email_address
  subject "Greetings from Rails!"
  from This email address is being protected from spambots. You need JavaScript enabled to view it.
  body "Your first Rails email message."

No more writing 50 to 100 lines of code to simply send an email, as is necessary in some other languages! Although it's not covered here, Action Mailer makes it easy to send file attachments as well.

That's Great, But What Are Its Weaknesses?

As always, it's important to understand both a technology's strengths and its weaknesses. Rails, like any other technology, certainly has its weaknesses. I'd have to say Rails' biggest weaknesses is its relative (to competing technologies) immaturity. While it debuted nearly three years ago, it hasn't been deployed nearly to the extent of some of its competitors (J2EE, PHP, ASP, .NET, etc.) such that the technologies can be accurately compared. Depending on the type of project in which you're involved, its relative "immaturity" may or may not be a show-stopper; that's a decision you'll have to make. It's noteworthy that the number of business-class Web sites using Rails is constantly growing. In the future, we can surely expect to see a wealth of technological comparisons (backed by documented results) as well as a rich set of texts explaining how to deploy Rails applications in those "advanced" scenarios. The best piece of advice I can offer here is to simply study, download, install, and work with Rails to get a feel for how it will work for you.

Supported Environments

Ruby on Rails ships in either source or binary form and is supported on most major *nix platforms, OS X, and Windows. As noted directly on the official Ruby on Rails Web site, Rails works with a wealth of Web servers and databases. Recommended Web servers include Apache or lighttpd running FastCGI, SCGI, or Mongrel. To make things even easier, Rails ships with WEBrick, its own pure-Ruby Web server. This means you can simply download Ruby and immediately start creating your first Rails Web site without the hassle and overhead of configuring a Web server. Potential databases include MySQL, PostgreSQL, SQLite, Oracle, SQL Server, DB2, or Firebird.

In terms of development environments to work with Ruby code, surely any text editor will suffice, but there is also an excellent Eclipse-based plug-in available called RadRails that makes developing Rails applications even easier. Whether or not you're already an Eclipse user, if you're going to work with Rails, RadRails is definitely worth an evaluation.

The Rails Community

Since its inception, Ruby on Rails has been increasingly gaining notoriety, so a lot of public communities have spawned into existence. There are a variety of resources out there for Rails developers, including mailing lists for help, wikis containing a breadth of Rails information, IRC chat rooms for real-time discussion, and much more! While you can find these resources just about anywhere, an excellent starting point is the official Ruby on Rails community Web site. All of these resources and communities help foster the maturity of the Rails framework; developers from all over the world can share their ideas and experiences to help lead you to successful projects.

Try Ruby on Rails for Yourself

In no way have I come remotely close to touching on all that Rails has to offer, but hopefully I have convinced you that Rails is worth spending a few hours of your time to investigate. If writing less code with less room for mistakes on Web-related projects is what you're seeking, Rails is definitely worth giving a try. Where do you go from here? Well, the wealth of simple tutorials on the Web can introduce you to Rails development and allow you to experience the niceties and benefits firsthand. Who knows, the next time your boss asks you to throw together a Web site, you might be able to put something together in no time! Don't take my word for it, though; give Ruby on Rails a try for yourself.

Joe Cropper is a Software Engineer at IBM in Rochester, Minnesota. Joe works as part of the System i Software Final System Test team, and his areas of expertise include database, multi-tiered client-server technologies, and a variety of object-oriented programming languages. Joe can be reached via email at This email address is being protected from spambots. You need JavaScript enabled to view it..

Joe Cropper is a Software Engineer at IBM in Rochester, Minnesota. He works as part of the Cloud Systems Software Development organization, focusing on virtualization and cloud management solutions. Joe has held a number of roles in other organizations as well, ranging from IBM i and Electronic Support. His areas of expertise include virtualization and cloud management, OpenStack, Java EE, and multi-tiered applications. Joe can be reached via email at



Support MC Press Online





  • White Paper: Node.js for Enterprise IBM i Modernization

    SB Profound WP 5539

    If your business is thinking about modernizing your legacy IBM i (also known as AS/400 or iSeries) applications, you will want to read this white paper first!

    Download this paper and learn how Node.js can ensure that you:
    - Modernize on-time and budget - no more lengthy, costly, disruptive app rewrites!
    - Retain your IBM i systems of record
    - Find and hire new development talent
    - Integrate new Node.js applications with your existing RPG, Java, .Net, and PHP apps
    - Extend your IBM i capabilties to include Watson API, Cloud, and Internet of Things

    Read Node.js for Enterprise IBM i Modernization Now!


  • Profound Logic Solution Guide

    SB Profound WP 5539More than ever, there is a demand for IT to deliver innovation.
    Your IBM i has been an essential part of your business operations for years. However, your organization may struggle to maintain the current system and implement new projects.
    The thousands of customers we've worked with and surveyed state that expectations regarding the digital footprint and vision of the companyare not aligned with the current IT environment.

    Get your copy of this important guide today!


  • 2022 IBM i Marketplace Survey Results

    Fortra2022 marks the eighth edition of the IBM i Marketplace Survey Results. Each year, Fortra captures data on how businesses use the IBM i platform and the IT and cybersecurity initiatives it supports.

    Over the years, this survey has become a true industry benchmark, revealing to readers the trends that are shaping and driving the market and providing insight into what the future may bring for this technology.

  • Brunswick bowls a perfect 300 with LANSA!

    FortraBrunswick is the leader in bowling products, services, and industry expertise for the development and renovation of new and existing bowling centers and mixed-use recreation facilities across the entertainment industry. However, the lifeblood of Brunswick’s capital equipment business was running on a 15-year-old software application written in Visual Basic 6 (VB6) with a SQL Server back-end. The application was at the end of its life and needed to be replaced.
    With the help of Visual LANSA, they found an easy-to-use, long-term platform that enabled their team to collaborate, innovate, and integrate with existing systems and databases within a single platform.
    Read the case study to learn how they achieved success and increased the speed of development by 30% with Visual LANSA.


  • Progressive Web Apps: Create a Universal Experience Across All Devices

    LANSAProgressive Web Apps allow you to reach anyone, anywhere, and on any device with a single unified codebase. This means that your applications—regardless of browser, device, or platform—instantly become more reliable and consistent. They are the present and future of application development, and more and more businesses are catching on.
    Download this whitepaper and learn:

    • How PWAs support fast application development and streamline DevOps
    • How to give your business a competitive edge using PWAs
    • What makes progressive web apps so versatile, both online and offline



  • The Power of Coding in a Low-Code Solution

    LANSAWhen it comes to creating your business applications, there are hundreds of coding platforms and programming languages to choose from. These options range from very complex traditional programming languages to Low-Code platforms where sometimes no traditional coding experience is needed.
    Download our whitepaper, The Power of Writing Code in a Low-Code Solution, and:

    • Discover the benefits of Low-code's quick application creation
    • Understand the differences in model-based and language-based Low-Code platforms
    • Explore the strengths of LANSA's Low-Code Solution to Low-Code’s biggest drawbacks



  • Why Migrate When You Can Modernize?

    LANSABusiness users want new applications now. Market and regulatory pressures require faster application updates and delivery into production. Your IBM i developers may be approaching retirement, and you see no sure way to fill their positions with experienced developers. In addition, you may be caught between maintaining your existing applications and the uncertainty of moving to something new.
    In this white paper, you’ll learn how to think of these issues as opportunities rather than problems. We’ll explore motivations to migrate or modernize, their risks and considerations you should be aware of before embarking on a (migration or modernization) project.
    Lastly, we’ll discuss how modernizing IBM i applications with optimized business workflows, integration with other technologies and new mobile and web user interfaces will enable IT – and the business – to experience time-added value and much more.


  • UPDATED: Developer Kit: Making a Business Case for Modernization and Beyond

    Profound Logic Software, Inc.Having trouble getting management approval for modernization projects? The problem may be you're not speaking enough "business" to them.

    This Developer Kit provides you study-backed data and a ready-to-use business case template to help get your very next development project approved!

  • What to Do When Your AS/400 Talent Retires

    FortraIT managers hoping to find new IBM i talent are discovering that the pool of experienced RPG programmers and operators or administrators is small.

    This guide offers strategies and software suggestions to help you plan IT staffing and resources and smooth the transition after your AS/400 talent retires. Read on to learn:

    • Why IBM i skills depletion is a top concern
    • How leading organizations are coping
    • Where automation will make the biggest impact


  • Node.js on IBM i Webinar Series Pt. 2: Setting Up Your Development Tools

    Profound Logic Software, Inc.Have you been wondering about Node.js? Our free Node.js Webinar Series takes you from total beginner to creating a fully-functional IBM i Node.js business application. In Part 2, Brian May teaches you the different tooling options available for writing code, debugging, and using Git for version control. Attend this webinar to learn:

    • Different tools to develop Node.js applications on IBM i
    • Debugging Node.js
    • The basics of Git and tools to help those new to it
    • Using as a pre-built development environment



  • Expert Tips for IBM i Security: Beyond the Basics

    SB PowerTech WC GenericIn this session, IBM i security expert Robin Tatam provides a quick recap of IBM i security basics and guides you through some advanced cybersecurity techniques that can help you take data protection to the next level. Robin will cover:

    • Reducing the risk posed by special authorities
    • Establishing object-level security
    • Overseeing user actions and data access

    Don't miss this chance to take your knowledge of IBM i security beyond the basics.



  • 5 IBM i Security Quick Wins

    SB PowerTech WC GenericIn today’s threat landscape, upper management is laser-focused on cybersecurity. You need to make progress in securing your systems—and make it fast.
    There’s no shortage of actions you could take, but what tactics will actually deliver the results you need? And how can you find a security strategy that fits your budget and time constraints?
    Join top IBM i security expert Robin Tatam as he outlines the five fastest and most impactful changes you can make to strengthen IBM i security this year.
    Your system didn’t become unsecure overnight and you won’t be able to turn it around overnight either. But quick wins are possible with IBM i security, and Robin Tatam will show you how to achieve them.

  • Security Bulletin: Malware Infection Discovered on IBM i Server!

    SB PowerTech WC GenericMalicious programs can bring entire businesses to their knees—and IBM i shops are not immune. It’s critical to grasp the true impact malware can have on IBM i and the network that connects to it. Attend this webinar to gain a thorough understanding of the relationships between:

    • Viruses, native objects, and the integrated file system (IFS)
    • Power Systems and Windows-based viruses and malware
    • PC-based anti-virus scanning versus native IBM i scanning

    There are a number of ways you can minimize your exposure to viruses. IBM i security expert Sandi Moore explains the facts, including how to ensure you're fully protected and compliant with regulations such as PCI.



  • Encryption on IBM i Simplified

    SB PowerTech WC GenericDB2 Field Procedures (FieldProcs) were introduced in IBM i 7.1 and have greatly simplified encryption, often without requiring any application changes. Now you can quickly encrypt sensitive data on the IBM i including PII, PCI, PHI data in your physical files and tables.
    Watch this webinar to learn how you can quickly implement encryption on the IBM i. During the webinar, security expert Robin Tatam will show you how to:

    • Use Field Procedures to automate encryption and decryption
    • Restrict and mask field level access by user or group
    • Meet compliance requirements with effective key management and audit trails


  • Lessons Learned from IBM i Cyber Attacks

    SB PowerTech WC GenericDespite the many options IBM has provided to protect your systems and data, many organizations still struggle to apply appropriate security controls.
    In this webinar, you'll get insight into how the criminals accessed these systems, the fallout from these attacks, and how the incidents could have been avoided by following security best practices.

    • Learn which security gaps cyber criminals love most
    • Find out how other IBM i organizations have fallen victim
    • Get the details on policies and processes you can implement to protect your organization, even when staff works from home

    You will learn the steps you can take to avoid the mistakes made in these examples, as well as other inadequate and misconfigured settings that put businesses at risk.



  • The Power of Coding in a Low-Code Solution

    SB PowerTech WC GenericWhen it comes to creating your business applications, there are hundreds of coding platforms and programming languages to choose from. These options range from very complex traditional programming languages to Low-Code platforms where sometimes no traditional coding experience is needed.
    Download our whitepaper, The Power of Writing Code in a Low-Code Solution, and:

    • Discover the benefits of Low-code's quick application creation
    • Understand the differences in model-based and language-based Low-Code platforms
    • Explore the strengths of LANSA's Low-Code Solution to Low-Code’s biggest drawbacks



  • Node Webinar Series Pt. 1: The World of Node.js on IBM i

    SB Profound WC GenericHave you been wondering about Node.js? Our free Node.js Webinar Series takes you from total beginner to creating a fully-functional IBM i Node.js business application.
    Part 1 will teach you what Node.js is, why it's a great option for IBM i shops, and how to take advantage of the ecosystem surrounding Node.
    In addition to background information, our Director of Product Development Scott Klement will demonstrate applications that take advantage of the Node Package Manager (npm).
    Watch Now.

  • The Biggest Mistakes in IBM i Security

    SB Profound WC Generic The Biggest Mistakes in IBM i Security
    Here’s the harsh reality: cybersecurity pros have to get their jobs right every single day, while an attacker only has to succeed once to do incredible damage.
    Whether that’s thousands of exposed records, millions of dollars in fines and legal fees, or diminished share value, it’s easy to judge organizations that fall victim. IBM i enjoys an enviable reputation for security, but no system is impervious to mistakes.
    Join this webinar to learn about the biggest errors made when securing a Power Systems server.
    This knowledge is critical for ensuring integrity of your application data and preventing you from becoming the next Equifax. It’s also essential for complying with all formal regulations, including SOX, PCI, GDPR, and HIPAA
    Watch Now.

  • Comply in 5! Well, actually UNDER 5 minutes!!

    SB CYBRA PPL 5382

    TRY the one package that solves all your document design and printing challenges on all your platforms.

    Produce bar code labels, electronic forms, ad hoc reports, and RFID tags – without programming! MarkMagic is the only document design and print solution that combines report writing, WYSIWYG label and forms design, and conditional printing in one integrated product.

    Request your trial now!

  • Backup and Recovery on IBM i: Your Strategy for the Unexpected

    FortraRobot automates the routine tasks of iSeries backup and recovery, saving you time and money and making the process safer and more reliable. Automate your backups with the Robot Backup and Recovery Solution. Key features include:
    - Simplified backup procedures
    - Easy data encryption
    - Save media management
    - Guided restoration
    - Seamless product integration
    Make sure your data survives when catastrophe hits. Try the Robot Backup and Recovery Solution FREE for 30 days.

  • Manage IBM i Messages by Exception with Robot

    SB HelpSystems SC 5413Managing messages on your IBM i can be more than a full-time job if you have to do it manually. How can you be sure you won’t miss important system events?
    Automate your message center with the Robot Message Management Solution. Key features include:
    - Automated message management
    - Tailored notifications and automatic escalation
    - System-wide control of your IBM i partitions
    - Two-way system notifications from your mobile device
    - Seamless product integration
    Try the Robot Message Management Solution FREE for 30 days.

  • Easiest Way to Save Money? Stop Printing IBM i Reports

    FortraRobot automates report bursting, distribution, bundling, and archiving, and offers secure, selective online report viewing.
    Manage your reports with the Robot Report Management Solution. Key features include:

    - Automated report distribution
    - View online without delay
    - Browser interface to make notes
    - Custom retention capabilities
    - Seamless product integration
    Rerun another report? Never again. Try the Robot Report Management Solution FREE for 30 days.

  • Hassle-Free IBM i Operations around the Clock

    SB HelpSystems SC 5413For over 30 years, Robot has been a leader in systems management for IBM i.
    Manage your job schedule with the Robot Job Scheduling Solution. Key features include:
    - Automated batch, interactive, and cross-platform scheduling
    - Event-driven dependency processing
    - Centralized monitoring and reporting
    - Audit log and ready-to-use reports
    - Seamless product integration
    Scale your software, not your staff. Try the Robot Job Scheduling Solution FREE for 30 days.