Use cases for Ruby on Rails, the web application framework based on the Ruby programming language. Learn problems that Ruby on Rails can solve, as well as how Ruby on Rails can be a useful solution for your project's needs.
Use Case: Ruby on Rails
The user in the following scenario is the lead programmer for a large software development company. The user has been tasked with finding a new solution for the company's development protocols, based on several criteria which are not being met by their current set of hand-made software components.
Scenario 1: Quick Scaffolding
In this scenario, the user needs to address the developers' needs for a system which provides quick scaffolding for their application framework. The developers need a way to quickly start up and run an application framework for testing purposes.
Ruby on Rails is an excellent solution for this issue, because it provides quick scaffolding with a flexible syntax. A single command will create an entire file system structure, including basic configurations and modules included.
For example, the following command will create a quick scaffold for a movie review application:
rails generate scaffold Movies title:string description:text rating:number
Scenario 2: Database Seeding
In creating their test applications, the developers need to be able to seed the database with basic sample information. In some cases, they need a large amount of sample data to be created and added to the database for testing purposes.
Ruby on Rails includes two ways to seed an application with data. The simplest method is to manually add the seed data to a file which is automatically uploaded when the project is created. For cases where more sample data is needed, the developers can use a Ruby gem like Faker to generate database seeds based on a number of specified criteria.
Scenario 3: Data Validation
In this scenario, the user needs to address the issue of data validation. The company is developing a web application which will take user-submitted data and pass it into a database. For security reasons, the data needs to be sanitized and validated before being added to the database.
Ruby on Rails offers several methods of data validation. Active Record includes a number of pre-defined data validation helpers, as explained in the Ruby on Rails user guide.
If these built-in validation helpers are not sufficient for the user's needs, Ruby on Rails also offers the ability to perform custom validations which can be written by the programmers to suit their exact specifications.