Why Rails ??
- 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.
- It follows Convention over configuration which helps the programmer a lot during decision making.
- 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
- As the rails user-base is increasing exponentially, the chances of this getting outdated is very slim.
- Controller is the place where the logic of the program is written.
- It receives all the requests from the application.
- The received requests are processed here, and appropriate response is created
- It is also used for just updating the database with new data.
it will be more clear as you go through one example.
- Models are nothing but your data bases.
- These are ruby classes where information are stored or retrieved.
- Views contain the dynamic web pages that the users will be seeing. While Models and controllers are kept behind the curtains.
- These pages connect the users with the server in the backend
- They are written in a special format called Embedded Ruby(.erb)
And Do learn about rails-scaffolding which generates the entire work that was done in the above tutorial in just one terminal command 🙂
It is better to keep 3 terminals open
- for rails c (rails console, this can be used during testing for manipulating data in server side without touching the website)
- rails s (for rails server)
- 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.