Home Blog News People Projects

Why Rails ??

  1. First of all it is very fast to code a project in rails. So have a this knowledge with us will be a very big advantage during coding competitions and hackathons.
  2. It follows Convention over configuration which helps the programmer a lot during decision making.
  3. There are plenty of gems(libraries) available which makes the development lot easier. And as the community is huge these libraries are always kept uptodate
  4. As the rails user-base is increasing exponentially, the chances of this getting outdated is very slim.

Controllers

  1. Controller is the place where the logic of the program is written.
  2. It receives all the requests from the application.
  3. The received requests are processed here, and appropriate response is created
  4. It is also used for just updating the database with new data.

it will be more clear as you go through one example.

Models

  1. Models are nothing but your data bases.
  2. These are ruby classes where information are stored or retrieved.

Views

  1. Views contain the dynamic web pages that the users will be seeing. While Models and controllers are kept behind the curtains.
  2. These pages connect the users with the server in the backend
  3. They are written in a special format called Embedded Ruby(.erb)

The official documentation explains the work flow in the best possible way with examples

And Do learn about rails-scaffolding which generates the entire work that was done in the above tutorial in just one terminal command :)

Going through all these will give deeper insights.

Other Thoughts:

  • It is better to keep 3 terminals open

    1. for rails c (rails console, this can be used during testing for manipulating data in server side without touching the website)
    2. rails s (for rails server)
    3. rails routes
  • Migration helps us in maintaining a version control for our database. So having clean migration files will help a lot, as it is very easy to roll back to previous versions.

  • Difference between render and redirect:

    Render function will generate the view to the browser, when render function is not called in the controller it generates the default view of the controller.

    Redirect tells the browser to make a entire new request to a page.

    It is not required to make new requests every time. So think before you use redirect function.

Special thanks to Biswesh for the session. Hope this helped.