Ruby on Rails - rails tutorial - Ruby on Rails MVC - ruby on rails tutorial - rails guides - rails tutorial - ruby rails
What is Ruby on Rails MVC?
- The Model View Controller principle divides the work of an application into three separate but closely cooperative subsystems.
![learn ruby on rails - ruby on rails tutorial - ruby on rails - rails code - model view controller - mvc - rails web application - ruby on rails examples](https://wikitechy.com/tutorials/ruby-on-rails/img/ruby-on-rails-images/ruby-on-rails-mvc-structure-code.png)
It basically works as following:
- Requests first come to the controller, controller finds an appropriate view and interacts with model which in turn interacts with database and send response to controller.
- Then controller gives the output to the view based on the response.
![learn ruby tutorial - model controller architecture in ruby rails mvc - ruby example](https://wikitechy.com/tutorials/ruby-on-rails/img/ruby-on-rails-images/ruby-rails-mvc-model-controller-architecture.gif)
Learn ruby - ruby tutorial - learn ruby tutorial - model controller architecture in ruby rails mvc - ruby example - ruby examples - ruby programs
![learn ruby on rails - ruby on rails tutorial - ruby on rails - rails framework- rails web application - ruby on rails examples](https://wikitechy.com/tutorials/ruby-on-rails/img/ruby-on-rails-images/rails-framework.png)
Step 1 - Browser request for ruby on rails web application :
![learn ruby on rails - ruby on rails tutorial - ruby on rails - model view controller - mvc - rails web application - ruby on rails examples](https://wikitechy.com/tutorials/ruby-on-rails/img/ruby-on-rails-images/learn-mvc.png)
ruby on rails tutorial tags - ruby , rail , ruby on rails , rail forum , ruby on rails tutorial , ruby tutorial , rails guides , rails tutorial , learn ruby
Step 2 - Browser request to the server for ruby on rails web application :
![learn ruby on rails - ruby on rails tutorial - ruby on rails - model view controller - mvc - rails web application - ruby on rails examples](https://wikitechy.com/tutorials/ruby-on-rails/img/ruby-on-rails-images/ruby-on-rails-model-view-controller-server-request.png)
ruby on rails tutorial tags - ruby , rail , ruby on rails , rail forum , ruby on rails tutorial , ruby tutorial , rails guides , rails tutorial , learn ruby
Step 3 - Web request to the server for ruby on rails redirected to MVC :
![learn ruby on rails - ruby on rails tutorial - ruby on rails - model view controller - mvc - rails web application - ruby on rails examples](https://wikitechy.com/tutorials/ruby-on-rails/img/ruby-on-rails-images/web-requests-redirected-to-mvc.png)
Step 4 - Web request in ruby on rails web application
-> redirected to controller in mvc :
![learn ruby on rails - ruby on rails tutorial - ruby on rails - model view controller - mvc - rails web application - ruby on rails examples](https://wikitechy.com/tutorials/ruby-on-rails/img/ruby-on-rails-images/controller-in-mvc.png)
ruby on rails tutorial tags - ruby , rail , ruby on rails , rail forum , ruby on rails tutorial , ruby tutorial , rails guides , rails tutorial , learn ruby
Step 5 - Web request in ruby on rails web application
-> redirected from controller
->to model in mvc :
![learn ruby on rails - ruby on rails tutorial - ruby on rails - model view controller - mvc - rails web application - ruby on rails examples](https://wikitechy.com/tutorials/ruby-on-rails/img/ruby-on-rails-images/access-ruby-on-rails-active-records.png)
Step 6 - Web request in ruby on rails web application
-> redirected from controller
-> to model
-> Access database in mvc :
![learn ruby on rails - ruby on rails tutorial - ruby on rails - model view controller - mvc - rails web application - ruby on rails examples](https://wikitechy.com/tutorials/ruby-on-rails/img/ruby-on-rails-images/ruby-on-rails-database.png)
Step 7 - Web request in ruby on rails web application
-> redirected from controller
-> to model
-> Access database
->Access active records in the database in mvc :
![learn ruby on rails - ruby on rails tutorial - ruby on rails - model view controller - mvc - rails web application - ruby on rails examples](https://wikitechy.com/tutorials/ruby-on-rails/img/ruby-on-rails-images/model-mvc.png)
ruby on rails tutorial tags - ruby , rail , ruby on rails , rail forum , ruby on rails tutorial , ruby tutorial , rails guides , rails tutorial , learn ruby
Step 8 - Web request in ruby on rails web application
-> redirected from controller
-> to model
-> Access database
->Access active records in the database -fetch active records and control back to controller in mvc :
![learn ruby on rails - ruby on rails tutorial - ruby on rails - model view controller - mvc - rails web application - ruby on rails examples](https://wikitechy.com/tutorials/ruby-on-rails/img/ruby-on-rails-images/active-controller-in-mvc.png)
Step 9 - Web request in ruby on rails web application
-> redirected from controller
-> to model
-> Access database
->Access active records in the database -fetch active records and control back to controller in mvc -> Feed data into HTML through Embedded Ruby:
![learn ruby on rails - ruby on rails tutorial - ruby on rails - model view controller - mvc - rails web application - ruby on rails examples](https://wikitechy.com/tutorials/ruby-on-rails/img/ruby-on-rails-images/embedded-ruby-web-application-ruby-on-rails.png)
Step 10 - Web request in ruby on rails web application
-> redirected from controller
-> to model
-> Access database
->Access active records in the database
-fetch active records and control back to controller in mvc
-> Feed data into HTML through Embedded Ruby
-> Data displayed as haml :
![learn ruby on rails - ruby on rails tutorial - ruby on rails - haml - HTMLabstraction markup language - model view controller - mvc - rails web application - ruby on rails examples](https://wikitechy.com/tutorials/ruby-on-rails/img/ruby-on-rails-images/HTMLabstraction-markup-language-haml.png)
Step 11 - Web request in ruby on rails web application
-> redirected from controller
-> to model
-> Access database
->Access active records in the database
-fetch active records and control back to controller in mvc
-> Feed data into HTML through Embedded Ruby
-> Data displayed as haml
-> Data displayed as HTML and displayed in the browser :
![learn ruby on rails - ruby on rails tutorial - ruby on rails - haml - HTMLabstraction markup language - model view controller - mvc - rails web application - ruby on rails examples](https://wikitechy.com/tutorials/ruby-on-rails/img/ruby-on-rails-images/ruby-on-rails-web-application.png)
![learn ruby on rails - ruby on rails tutorial - ruby on rails - haml - HTMLabstraction markup language - model view controller - mvc - rails web application - ruby on rails examples](https://wikitechy.com/tutorials/ruby-on-rails/img/ruby-on-rails-images/ruby-on-rails-browser-web-applicatoin.png)