Completing Your Program

Optional Node
Premium Content - Free Preview

Overview of Your Program

You created a simple program that lets people create and read products from command line. You learned about Ruby while building a program that's like a mini-version of Ruby on Rails itself.

The Product class you created was used for storing information about products. In your program, each instance of Product was stored in an array. In a Rails application, this information would be stored in an actual database, where no 'objects' exist.

Q: How can a row of data from a database be treated like an Object Instance in Rails?
A: Ruby on Rails provides the ActiveRecord framework so you can treat each row in your database (or "record") like an actual instance.

The Model class you created is like a model class you would create in Ruby on Rails. For example, you could create a model called Product that would store products in a database. All models in Rails inherit from the Rails class ActiveRecord, which give them their special powers!

The Controller class you created is like a controller in Rails. For example, you could create a ProductsController class in Rails for controlling access to pages that relate to your products. Each page would be represented by a method in your Controller class. All controllers in Rails inherit from the Rails class ApplicationController.


End of Free Content Preview. Please Sign in or Sign up to buy premium content.

Contact Us
Sign in or email us at [email protected]