In this tip I am going to demonstrate how to create your first basic Rails application without writing a single line of Ruby code.
Rails has a beautiful concept called scaffolding,using which a novice programmer can also create his first Rails App.
Just follow 5 basic steps and get your first App ready.
Step1 : Create your Rails Project
$ rails new MyFirstApp
$ cd MyFirstApp #Get inside your created project directory.
Description: Just created our rails project directory and we got inside project folder.
Step2: Create your complete app in one line
$ rails generate scaffold ShoppingCart item_name:string price:integer purchased_on:date
In just one line of command we created our complete ShoppingCart having fields item_name(of string type), price(Of integer type), purchased_on(of Date type).
We created our complete Model, View, Controller and most important migration files(for creating our shoppingcarts table)
DB section is yet to be updated, follow Step-3.
Step3 : Update your DB
$ rake db:migrate
Description: This will create complete table shoppingcarts in our database.
Step4: Start Rails Server
$ rails server
Description: On entering above command, our rails server will be started at http://0.0.0.0:3000/ (same as localhost:3000)
Just enter this URL in your browser and you will get the default rails page.
Step5: Check your complete App
In Browser enter localhost:3000/shoppingcarts/new
Now just keep adding values to the fields, submit it, list it, see individual records.
Hurrah!!! As I had promised, we are done with our first rails app without writing a single line.