Scaffolding with Ruby on Rails
Ruby on Rails (ROR) is famous with web developers for a million reasons – one of the biggest being the scaffolding feature, which lets you to create web applications based on the database within minutes! Here, we see how ROR and MySQL combine to create fast, clean and efficient web applications!
1. Create a ROR Application
An empty application has to be created first using the following command:
2. Create a database for the application
A database on which the scaffolding application will be based has to be created using MySQL basic commands:
create database db_name;
grant all priviledges on db_name.* to ‘user@localhost’ identified by ‘password’
3. Change the database settings of ROR
The database.yml file needs to be updated with the new database name so that the application can connect to the database.
4. Create the tables, model and controller
The table has to be created with the CREATE TABLE command of MySQL, and the ROR model and controller has to be also created by the following commands:
ruby script\generate model application_name
ruby script\generate controller application_name
5. Change the controller file to begin scaffolding
The application_name_controller.rb file could be located from the path app/controller and has to modified by adding the following line
class Application_nameController < ApplicationController
This will lead to the automatic creation of the following interfaces: creating new entries, editing new entries, viewing existing entries and deleting existing entries!
BounceWeb provides great deals on ROR hosting!
Leave a Reply
You must be logged in to post a comment.