Tuesday, April 18, 2017

Getting Started with Rails

The older version of Rails start up page shows a link that re-directs users to http://guides.rubyonrails.org/getting_started.html - Getting Started with Rails tutorial. In the tutorial, it explains how to build a simple web log (blog) using Ruby on Rails framework from scratch.



User can access to the blog by either as registered user or as a guest.
A guest can:
  • View the article list of the blog
  • View the text (details) of each article
  • Add a comment
A registered user with user name and password can also do the functions of a guest with these additional functions:
  • Add a new article
  • Edit an article
  • Destroy (delete) an article
  • Destroy a comment
I have completed the tutorial which takes around 1 - 2 hours. And I have uploaded the project on Github:https://github.com/jimmy2046/gettingstarttedwithrails . You can clone (download) to you computer using git by the following command on Linux shell:
git clone https://github.com/jimmy2046/gettingstarttedwithrails
Sample outputs:
Cloning into 'gettingstarttedwithrails'...
remote: Counting objects: 121, done.
remote: Compressing objects: 100% (100/100), done.
remote: Total 121 (delta 6), reused 121 (delta 6), pack-reused 0
Receiving objects: 100% (121/121), 25.45 KiB | 0 bytes/s, done.
Resolving deltas: 100% (6/6), done.
Checking connectivity... done.
It will download all the files and directory structure into your computer named gettingstarttedwithrails.
/home/yourname/gettingstarttedwithrails
Or
~/gettingstarttedwithrails

Change into the directory gettingstarttedwithrails:
cd gettingstarttedwithrails
Start the Rails server:
rails server
In Firefox, type: http://localhost:3000/ Then, it will show up Pending Migration Error. In the other words: database migration is need.


Open a new shell terminal windows and type database migration command in Linux prompt:
cd gettingstarttedwithrails
rails db:migrate RAILS_ENV=development
Now reload the http://localhost:3000/ link in Firefox. It will bring you to the Hello Rails index page.
Click the My Blog link and it will bring you to blog listing page. You can add a new article by clicking the New article link. That will initiate a controller to add a new article. You will need a user name and password for adding a post.
  • User Name: "dhh"
  • Password: "secret"
You can also add a comment if you wish. You can press the back link to go to article listing.

This is the first magic of Ruby on Rails.

1 comment:

  1. Really Good blog post.provided a helpful information.I hope that you will post more updates like this Ruby on Rails Online Training
    Bangalore

    ReplyDelete

How to kill an abandoned process in Linux/Unix

I remembered it, then I forgot, then I remembered it, and then I forgot again. In case of a Linux/Unit process hang, I have to figure out ...