SlideShare a Scribd company logo
Principles of MVC For rails Developers
View Ruby On Rails Course at: www.edureka.co/ruby-on-rails
For more details please contact us:
US : 1800 275 9730 (toll free)
INDIA : +91 88808 62004
Email Us : webinars@edureka.co
For Queries:
Post on Twitter @edurekaIN: #askEdureka
Post on Facebook /edurekaIN
Slide 2 www.edureka.co/ruby-on-rails
Objectives
At the end of this module, you will be able to understand:
 Challenges Faced when Designing an Application Without Framework
 MCV Design Patterns
 Logic Behind MVC
 DRY and Convention Over Configuration
 MVC Benefits
 Demo on MVC in RAILS
Slide 3 www.edureka.co/ruby-on-rails
Challenges Faced when Designing an Application without a Framework
 Complexity in direct coding  Everything must be tested, which is difficult
 Difficult to re-use code
 Hard code everything from
scratch
 Teamwork challenges -
parallel programming cannot
be done efficiently
Slide 4 www.edureka.co/ruby-on-rails
 Leads to disorganization  Change one thing, break another
Challenges Faced when Designing an Application without a Framework
Slide 5 www.edureka.co/ruby-on-rails
The Solution is to use Design Patterns
Design Patterns is the way to organize a program
in a proper manner
One such design pattern is MVC
Slide 6 www.edureka.co/ruby-on-rails
Introduction – What is MVC
MVC Introduction
MVC is acronym for Model-View-Controller
A software design pattern for developing web and desktop applications
In simple words, a better way of separating the logic of your application from
the display.
Slide 7 www.edureka.co/ruby-on-rails
 Originally described in terms of a design pattern for use with Smalltalk by Trygve Reenskaug in 1979.
 His paper was published under the title "Applications Programming in Smalltalk-80: How to use Model-View-
Controller", and paved the groundwork for most future MVC implementations.
 MVC design pattern is used to separate an application’s data, business logic, and presentation; doing so facilitates
the creation of more maintainable, reusable, and testable code.
• Model - Data Layer
• View - User Interface Layer
• Controller - Interacts with the Model
MVC Introduction
Slide 8 www.edureka.co/ruby-on-rails
MVC - Illustration
Web
Browser/Client
HTTP Request
HTTP Response
CONTROLLER MODEL
VIEW
Data object
Request
Data Objects
Response
Render dataEvents
(GET/POST)
Handled by Framework
(Hidden from user)
Database
Database
Request
Raw Data
Response
MVC Container
Website User
http://www.mywebsite.com
Slide 9 www.edureka.co/ruby-on-rails
Model
Data access routines and some business logic can be defined in the model.
Model is responsible for providing the data from the database and saving the data
into the data store.
Models are active representations of database tables: they can connect to your
database, query it (if instructed to do so by a controller) and save data to the
database.
No interaction between models and views: all the logic is handled by controllers.
MVC - Data Layer
Slide 10 www.edureka.co/ruby-on-rails
View
Views define exactly what is presented to the user.
It collects data from the user and gives it to controller and controller invokes the
required model.
Controllers pass data to each view to render in some format.
Views can be described as template files that present their content to the user:
variables, arrays and objects that are used in views are registered through a
controller.
Views should not contain complex business logic; only the elementary control
structures necessary to perform particular operations, such as the iteration of
collected data through a foreach construct, should be contained within a view.
MVC - User Interface Layer
Slide 11 www.edureka.co/ruby-on-rails
Controller
Controllers bind the whole pattern together.
Controller is intermediary between View and Model.
Controllers contain the logic of your application.
Each controller can offer different functionality; controllers retrieve and modify data by
accessing database tables through models; and they register variables and objects, which
can be used in views.
Once request is received from client it executes the appropriate business logic from the
model, decide which view to display based on the user's request and other factors, pass
along the data that each view will need, or hand off control to another controller entirely.
MVC - Interacting With Model
Slide 12 www.edureka.co/ruby-on-rails
DRY
 DRY just means "Don't Repeat Yourself". Make sure that when you write code, you only write it one time.
 The DRY principle is stated as "Every piece of knowledge must have a single, unambiguous, authoritative
representation within a system."
Reference: https://maurits.wordpress.com
Slide 13 www.edureka.co/ruby-on-rails
Convention Over Configuration
 Convention over configuration (also known as coding by convention) is a software design paradigm which seeks
to :
 For example, if there is a class Sale in the model, the corresponding table in the database is called "sales" by default.
It is only if one deviates from this convention, such as calling the table "product sales", that one needs to write code
regarding these names.
Not losing
flexibility
Decrease
number of
decisions on
developers
Gain
Simplicity
Slide 14 www.edureka.co/ruby-on-rails
MVC Benefits
Slide 15 www.edureka.co/ruby-on-rails
 Rails application can be created using the following command
>rails new app_name
 When you create an application using the rails helper script, you can see that a new directly structure is
created for your application. The directory structure will have to following directories that will be explained in
the next slide.
Creating a Rails Application
Slide 16 www.edureka.co/ruby-on-rails
Directory Layout
File /Folder Purpose
app/
Contains the controllers, models, views, helpers, mailers and assets for your
application.
bin/
Contains the rails script that starts your app and can contain other scripts you use to
deploy or run your application.
config/ Configure your application's routes, database, and more
condig.ru Rack configuration for Rack based servers used to start the application.
db/ Contains your current database schema, as well as the database migrations
Gemfile
Gemfile.lock
These files allow you to specify what gem dependencies are needed for your Rails
application. These files are used by the Bundler gem.
Lib/ Extended modules for you application
Log/ Application log files
Slide 17 www.edureka.co/ruby-on-rails
Directory Layout (Contd.)
File /Folder Purpose
public/ The only folder seen by the world as-is. Contains static files and compiled assets.
Rakefile
This file locates and loads tasks that can be run from the command line. Rather than
changing Rakefile, you should add your own tasks by adding files to the lib/tasks
directory of your application
README.rdoc
This is a brief instruction manual for your application. You should edit this file to tell
others what your application does, how to set it up, and so on.
test/ Unit tests, fixtures, and other test apparatus.
tmp/ Temporary files (like cache, pid, and session files).
Vendor/
A place for all third-party code. In a typical Rails application this includes vendor’s
gems.
Slide 18 www.edureka.co/ruby-on-rails
 Rails application can be booted using the
following command
>rails server
 This command will fire up WEBrick, a web
server distributed with Ruby.
» Default environment is development
» Default port is 3000
» http://127.0.0.1:3000
Running Rails Application
Slide 19 www.edureka.co/ruby-on-rails
To see your application in action, open a browser window and navigate to http://localhost:3000
Running Rails Application (Contd.)
Slide 20 www.edureka.co/ruby-on-rails
Demo on
MVC in Rails
Questions
Slide 21 www.edureka.co/ruby-on-railsTwitter @edurekaIN, Facebook /edurekaIN, use #AskEdureka for Questions
Principles of MVC for Rails Developers

More Related Content

What's hot

MSDN - ASP.NET MVC
MSDN - ASP.NET MVCMSDN - ASP.NET MVC
MSDN - ASP.NET MVC
Maarten Balliauw
 
Asp.net MVC training session
Asp.net MVC training sessionAsp.net MVC training session
Asp.net MVC training session
Hrichi Mohamed
 
An introduction to MongoDB
An introduction to MongoDBAn introduction to MongoDB
An introduction to MongoDB
Universidade de São Paulo
 
Introduction to ASP.NET Core
Introduction to ASP.NET CoreIntroduction to ASP.NET Core
Introduction to ASP.NET Core
Avanade Nederland
 
JavaScript - Chapter 5 - Operators
 JavaScript - Chapter 5 - Operators JavaScript - Chapter 5 - Operators
JavaScript - Chapter 5 - Operators
WebStackAcademy
 
Ppt of Basic MVC Structure
Ppt of Basic MVC StructurePpt of Basic MVC Structure
Ppt of Basic MVC Structure
Dipika Wadhvani
 
State management
State managementState management
State management
teach4uin
 
Web api
Web apiWeb api
ADF Bindings & Data Controls
ADF Bindings & Data ControlsADF Bindings & Data Controls
ADF Bindings & Data Controls
Rohan Walia
 
Angular - Chapter 7 - HTTP Services
Angular - Chapter 7 - HTTP ServicesAngular - Chapter 7 - HTTP Services
Angular - Chapter 7 - HTTP Services
WebStackAcademy
 
Blazor
BlazorBlazor
React JS - A quick introduction tutorial
React JS - A quick introduction tutorialReact JS - A quick introduction tutorial
React JS - A quick introduction tutorial
Mohammed Fazuluddin
 
Asp Net Advance Topics
Asp Net Advance TopicsAsp Net Advance Topics
Asp Net Advance TopicsAli Taki
 
Why MVC?
Why MVC?Why MVC?
Why MVC?
Wayne Tun Myint
 
Angular
AngularAngular
Angular
Lilia Sfaxi
 
Sharing Data Between Angular Components
Sharing Data Between Angular ComponentsSharing Data Between Angular Components
Sharing Data Between Angular Components
Squash Apps Pvt Ltd
 
Asp.Net Core MVC , Razor page , Entity Framework Core
Asp.Net Core MVC , Razor page , Entity Framework CoreAsp.Net Core MVC , Razor page , Entity Framework Core
Asp.Net Core MVC , Razor page , Entity Framework Core
mohamed elshafey
 
Migrating .NET Application to .NET Core
Migrating .NET Application to .NET CoreMigrating .NET Application to .NET Core
Migrating .NET Application to .NET Core
Baris Ceviz
 
Soap and restful webservice
Soap and restful webserviceSoap and restful webservice
Soap and restful webservice
Dong Ngoc
 

What's hot (20)

MSDN - ASP.NET MVC
MSDN - ASP.NET MVCMSDN - ASP.NET MVC
MSDN - ASP.NET MVC
 
Asp.net MVC training session
Asp.net MVC training sessionAsp.net MVC training session
Asp.net MVC training session
 
An introduction to MongoDB
An introduction to MongoDBAn introduction to MongoDB
An introduction to MongoDB
 
Introduction to ASP.NET Core
Introduction to ASP.NET CoreIntroduction to ASP.NET Core
Introduction to ASP.NET Core
 
JavaScript - Chapter 5 - Operators
 JavaScript - Chapter 5 - Operators JavaScript - Chapter 5 - Operators
JavaScript - Chapter 5 - Operators
 
Ppt of Basic MVC Structure
Ppt of Basic MVC StructurePpt of Basic MVC Structure
Ppt of Basic MVC Structure
 
State management
State managementState management
State management
 
Web api
Web apiWeb api
Web api
 
ADF Bindings & Data Controls
ADF Bindings & Data ControlsADF Bindings & Data Controls
ADF Bindings & Data Controls
 
Angular - Chapter 7 - HTTP Services
Angular - Chapter 7 - HTTP ServicesAngular - Chapter 7 - HTTP Services
Angular - Chapter 7 - HTTP Services
 
Blazor
BlazorBlazor
Blazor
 
React JS - A quick introduction tutorial
React JS - A quick introduction tutorialReact JS - A quick introduction tutorial
React JS - A quick introduction tutorial
 
Asp Net Advance Topics
Asp Net Advance TopicsAsp Net Advance Topics
Asp Net Advance Topics
 
Why MVC?
Why MVC?Why MVC?
Why MVC?
 
Angular
AngularAngular
Angular
 
Sharing Data Between Angular Components
Sharing Data Between Angular ComponentsSharing Data Between Angular Components
Sharing Data Between Angular Components
 
Asp.Net Core MVC , Razor page , Entity Framework Core
Asp.Net Core MVC , Razor page , Entity Framework CoreAsp.Net Core MVC , Razor page , Entity Framework Core
Asp.Net Core MVC , Razor page , Entity Framework Core
 
Migrating .NET Application to .NET Core
Migrating .NET Application to .NET CoreMigrating .NET Application to .NET Core
Migrating .NET Application to .NET Core
 
MVC Framework
MVC FrameworkMVC Framework
MVC Framework
 
Soap and restful webservice
Soap and restful webserviceSoap and restful webservice
Soap and restful webservice
 

Similar to Principles of MVC for Rails Developers

Principles of MVC for PHP Developers
Principles of MVC for PHP DevelopersPrinciples of MVC for PHP Developers
Principles of MVC for PHP Developers
Edureka!
 
Building Application with Ruby On Rails Framework
Building Application with Ruby On Rails FrameworkBuilding Application with Ruby On Rails Framework
Building Application with Ruby On Rails Framework
Edureka!
 
IRJET- Lightweight MVC Framework in PHP
IRJET- Lightweight MVC Framework in PHPIRJET- Lightweight MVC Framework in PHP
IRJET- Lightweight MVC Framework in PHP
IRJET Journal
 
MVC Demystified: Essence of Ruby on Rails
MVC Demystified: Essence of Ruby on RailsMVC Demystified: Essence of Ruby on Rails
MVC Demystified: Essence of Ruby on Rails
codeinmotion
 
Asp.net mvc 5 course module 1 overview
Asp.net mvc 5 course   module 1 overviewAsp.net mvc 5 course   module 1 overview
Asp.net mvc 5 course module 1 overview
Sergey Seletsky
 
Building Restful Web App Rapidly in CakePHP
Building Restful Web App Rapidly in CakePHPBuilding Restful Web App Rapidly in CakePHP
Building Restful Web App Rapidly in CakePHP
Edureka!
 
Rapid Development With CakePHP
Rapid Development With CakePHPRapid Development With CakePHP
Rapid Development With CakePHP
Edureka!
 
49.INS2065.Computer Based Technologies.TA.NguyenDucAnh.pdf
49.INS2065.Computer Based Technologies.TA.NguyenDucAnh.pdf49.INS2065.Computer Based Technologies.TA.NguyenDucAnh.pdf
49.INS2065.Computer Based Technologies.TA.NguyenDucAnh.pdf
cNguyn506241
 
Programming is Fun with ASP.NET MVC
Programming is Fun with ASP.NET MVCProgramming is Fun with ASP.NET MVC
Programming is Fun with ASP.NET MVC
Ian Carnaghan
 
MVC
MVCMVC
Asp 1a-aspnetmvc
Asp 1a-aspnetmvcAsp 1a-aspnetmvc
Asp 1a-aspnetmvc
Fajar Baskoro
 
Aspnetmvc 1
Aspnetmvc 1Aspnetmvc 1
Aspnetmvc 1
Fajar Baskoro
 
Avigma Tech LLC- Why the MVC pattern so popular?
Avigma Tech LLC- Why the MVC pattern so popular?Avigma Tech LLC- Why the MVC pattern so popular?
Avigma Tech LLC- Why the MVC pattern so popular?
Mike Brown
 
Webinar: Spring Framework - Introduction to Spring WebMVC & Spring with BigData
Webinar: Spring Framework - Introduction to Spring WebMVC & Spring with BigData Webinar: Spring Framework - Introduction to Spring WebMVC & Spring with BigData
Webinar: Spring Framework - Introduction to Spring WebMVC & Spring with BigData
Edureka!
 
Building Web Application Using Spring Framework
Building Web Application Using Spring FrameworkBuilding Web Application Using Spring Framework
Building Web Application Using Spring Framework
Edureka!
 
A Tour of Ruby On Rails
A Tour of Ruby On RailsA Tour of Ruby On Rails
A Tour of Ruby On Rails
David Keener
 

Similar to Principles of MVC for Rails Developers (20)

Principles of MVC for PHP Developers
Principles of MVC for PHP DevelopersPrinciples of MVC for PHP Developers
Principles of MVC for PHP Developers
 
Building Application with Ruby On Rails Framework
Building Application with Ruby On Rails FrameworkBuilding Application with Ruby On Rails Framework
Building Application with Ruby On Rails Framework
 
IRJET- Lightweight MVC Framework in PHP
IRJET- Lightweight MVC Framework in PHPIRJET- Lightweight MVC Framework in PHP
IRJET- Lightweight MVC Framework in PHP
 
MVC Demystified: Essence of Ruby on Rails
MVC Demystified: Essence of Ruby on RailsMVC Demystified: Essence of Ruby on Rails
MVC Demystified: Essence of Ruby on Rails
 
MVC & backbone.js
MVC & backbone.jsMVC & backbone.js
MVC & backbone.js
 
Asp.net mvc 5 course module 1 overview
Asp.net mvc 5 course   module 1 overviewAsp.net mvc 5 course   module 1 overview
Asp.net mvc 5 course module 1 overview
 
Building Restful Web App Rapidly in CakePHP
Building Restful Web App Rapidly in CakePHPBuilding Restful Web App Rapidly in CakePHP
Building Restful Web App Rapidly in CakePHP
 
Rapid Development With CakePHP
Rapid Development With CakePHPRapid Development With CakePHP
Rapid Development With CakePHP
 
49.INS2065.Computer Based Technologies.TA.NguyenDucAnh.pdf
49.INS2065.Computer Based Technologies.TA.NguyenDucAnh.pdf49.INS2065.Computer Based Technologies.TA.NguyenDucAnh.pdf
49.INS2065.Computer Based Technologies.TA.NguyenDucAnh.pdf
 
Programming is Fun with ASP.NET MVC
Programming is Fun with ASP.NET MVCProgramming is Fun with ASP.NET MVC
Programming is Fun with ASP.NET MVC
 
MVC
MVCMVC
MVC
 
Asp 1a-aspnetmvc
Asp 1a-aspnetmvcAsp 1a-aspnetmvc
Asp 1a-aspnetmvc
 
Aspnetmvc 1
Aspnetmvc 1Aspnetmvc 1
Aspnetmvc 1
 
MVC 4
MVC 4MVC 4
MVC 4
 
Avigma Tech LLC- Why the MVC pattern so popular?
Avigma Tech LLC- Why the MVC pattern so popular?Avigma Tech LLC- Why the MVC pattern so popular?
Avigma Tech LLC- Why the MVC pattern so popular?
 
CG_CS25010_Lecture
CG_CS25010_LectureCG_CS25010_Lecture
CG_CS25010_Lecture
 
Webinar: Spring Framework - Introduction to Spring WebMVC & Spring with BigData
Webinar: Spring Framework - Introduction to Spring WebMVC & Spring with BigData Webinar: Spring Framework - Introduction to Spring WebMVC & Spring with BigData
Webinar: Spring Framework - Introduction to Spring WebMVC & Spring with BigData
 
Building Web Application Using Spring Framework
Building Web Application Using Spring FrameworkBuilding Web Application Using Spring Framework
Building Web Application Using Spring Framework
 
Intro ASP MVC
Intro ASP MVCIntro ASP MVC
Intro ASP MVC
 
A Tour of Ruby On Rails
A Tour of Ruby On RailsA Tour of Ruby On Rails
A Tour of Ruby On Rails
 

More from Edureka!

What to learn during the 21 days Lockdown | Edureka
What to learn during the 21 days Lockdown | EdurekaWhat to learn during the 21 days Lockdown | Edureka
What to learn during the 21 days Lockdown | Edureka
Edureka!
 
Top 10 Dying Programming Languages in 2020 | Edureka
Top 10 Dying Programming Languages in 2020 | EdurekaTop 10 Dying Programming Languages in 2020 | Edureka
Top 10 Dying Programming Languages in 2020 | Edureka
Edureka!
 
Top 5 Trending Business Intelligence Tools | Edureka
Top 5 Trending Business Intelligence Tools | EdurekaTop 5 Trending Business Intelligence Tools | Edureka
Top 5 Trending Business Intelligence Tools | Edureka
Edureka!
 
Tableau Tutorial for Data Science | Edureka
Tableau Tutorial for Data Science | EdurekaTableau Tutorial for Data Science | Edureka
Tableau Tutorial for Data Science | Edureka
Edureka!
 
Python Programming Tutorial | Edureka
Python Programming Tutorial | EdurekaPython Programming Tutorial | Edureka
Python Programming Tutorial | Edureka
Edureka!
 
Top 5 PMP Certifications | Edureka
Top 5 PMP Certifications | EdurekaTop 5 PMP Certifications | Edureka
Top 5 PMP Certifications | Edureka
Edureka!
 
Top Maven Interview Questions in 2020 | Edureka
Top Maven Interview Questions in 2020 | EdurekaTop Maven Interview Questions in 2020 | Edureka
Top Maven Interview Questions in 2020 | Edureka
Edureka!
 
Linux Mint Tutorial | Edureka
Linux Mint Tutorial | EdurekaLinux Mint Tutorial | Edureka
Linux Mint Tutorial | Edureka
Edureka!
 
How to Deploy Java Web App in AWS| Edureka
How to Deploy Java Web App in AWS| EdurekaHow to Deploy Java Web App in AWS| Edureka
How to Deploy Java Web App in AWS| Edureka
Edureka!
 
Importance of Digital Marketing | Edureka
Importance of Digital Marketing | EdurekaImportance of Digital Marketing | Edureka
Importance of Digital Marketing | Edureka
Edureka!
 
RPA in 2020 | Edureka
RPA in 2020 | EdurekaRPA in 2020 | Edureka
RPA in 2020 | Edureka
Edureka!
 
Email Notifications in Jenkins | Edureka
Email Notifications in Jenkins | EdurekaEmail Notifications in Jenkins | Edureka
Email Notifications in Jenkins | Edureka
Edureka!
 
EA Algorithm in Machine Learning | Edureka
EA Algorithm in Machine Learning | EdurekaEA Algorithm in Machine Learning | Edureka
EA Algorithm in Machine Learning | Edureka
Edureka!
 
Cognitive AI Tutorial | Edureka
Cognitive AI Tutorial | EdurekaCognitive AI Tutorial | Edureka
Cognitive AI Tutorial | Edureka
Edureka!
 
AWS Cloud Practitioner Tutorial | Edureka
AWS Cloud Practitioner Tutorial | EdurekaAWS Cloud Practitioner Tutorial | Edureka
AWS Cloud Practitioner Tutorial | Edureka
Edureka!
 
Blue Prism Top Interview Questions | Edureka
Blue Prism Top Interview Questions | EdurekaBlue Prism Top Interview Questions | Edureka
Blue Prism Top Interview Questions | Edureka
Edureka!
 
Big Data on AWS Tutorial | Edureka
Big Data on AWS Tutorial | Edureka Big Data on AWS Tutorial | Edureka
Big Data on AWS Tutorial | Edureka
Edureka!
 
A star algorithm | A* Algorithm in Artificial Intelligence | Edureka
A star algorithm | A* Algorithm in Artificial Intelligence | EdurekaA star algorithm | A* Algorithm in Artificial Intelligence | Edureka
A star algorithm | A* Algorithm in Artificial Intelligence | Edureka
Edureka!
 
Kubernetes Installation on Ubuntu | Edureka
Kubernetes Installation on Ubuntu | EdurekaKubernetes Installation on Ubuntu | Edureka
Kubernetes Installation on Ubuntu | Edureka
Edureka!
 
Introduction to DevOps | Edureka
Introduction to DevOps | EdurekaIntroduction to DevOps | Edureka
Introduction to DevOps | Edureka
Edureka!
 

More from Edureka! (20)

What to learn during the 21 days Lockdown | Edureka
What to learn during the 21 days Lockdown | EdurekaWhat to learn during the 21 days Lockdown | Edureka
What to learn during the 21 days Lockdown | Edureka
 
Top 10 Dying Programming Languages in 2020 | Edureka
Top 10 Dying Programming Languages in 2020 | EdurekaTop 10 Dying Programming Languages in 2020 | Edureka
Top 10 Dying Programming Languages in 2020 | Edureka
 
Top 5 Trending Business Intelligence Tools | Edureka
Top 5 Trending Business Intelligence Tools | EdurekaTop 5 Trending Business Intelligence Tools | Edureka
Top 5 Trending Business Intelligence Tools | Edureka
 
Tableau Tutorial for Data Science | Edureka
Tableau Tutorial for Data Science | EdurekaTableau Tutorial for Data Science | Edureka
Tableau Tutorial for Data Science | Edureka
 
Python Programming Tutorial | Edureka
Python Programming Tutorial | EdurekaPython Programming Tutorial | Edureka
Python Programming Tutorial | Edureka
 
Top 5 PMP Certifications | Edureka
Top 5 PMP Certifications | EdurekaTop 5 PMP Certifications | Edureka
Top 5 PMP Certifications | Edureka
 
Top Maven Interview Questions in 2020 | Edureka
Top Maven Interview Questions in 2020 | EdurekaTop Maven Interview Questions in 2020 | Edureka
Top Maven Interview Questions in 2020 | Edureka
 
Linux Mint Tutorial | Edureka
Linux Mint Tutorial | EdurekaLinux Mint Tutorial | Edureka
Linux Mint Tutorial | Edureka
 
How to Deploy Java Web App in AWS| Edureka
How to Deploy Java Web App in AWS| EdurekaHow to Deploy Java Web App in AWS| Edureka
How to Deploy Java Web App in AWS| Edureka
 
Importance of Digital Marketing | Edureka
Importance of Digital Marketing | EdurekaImportance of Digital Marketing | Edureka
Importance of Digital Marketing | Edureka
 
RPA in 2020 | Edureka
RPA in 2020 | EdurekaRPA in 2020 | Edureka
RPA in 2020 | Edureka
 
Email Notifications in Jenkins | Edureka
Email Notifications in Jenkins | EdurekaEmail Notifications in Jenkins | Edureka
Email Notifications in Jenkins | Edureka
 
EA Algorithm in Machine Learning | Edureka
EA Algorithm in Machine Learning | EdurekaEA Algorithm in Machine Learning | Edureka
EA Algorithm in Machine Learning | Edureka
 
Cognitive AI Tutorial | Edureka
Cognitive AI Tutorial | EdurekaCognitive AI Tutorial | Edureka
Cognitive AI Tutorial | Edureka
 
AWS Cloud Practitioner Tutorial | Edureka
AWS Cloud Practitioner Tutorial | EdurekaAWS Cloud Practitioner Tutorial | Edureka
AWS Cloud Practitioner Tutorial | Edureka
 
Blue Prism Top Interview Questions | Edureka
Blue Prism Top Interview Questions | EdurekaBlue Prism Top Interview Questions | Edureka
Blue Prism Top Interview Questions | Edureka
 
Big Data on AWS Tutorial | Edureka
Big Data on AWS Tutorial | Edureka Big Data on AWS Tutorial | Edureka
Big Data on AWS Tutorial | Edureka
 
A star algorithm | A* Algorithm in Artificial Intelligence | Edureka
A star algorithm | A* Algorithm in Artificial Intelligence | EdurekaA star algorithm | A* Algorithm in Artificial Intelligence | Edureka
A star algorithm | A* Algorithm in Artificial Intelligence | Edureka
 
Kubernetes Installation on Ubuntu | Edureka
Kubernetes Installation on Ubuntu | EdurekaKubernetes Installation on Ubuntu | Edureka
Kubernetes Installation on Ubuntu | Edureka
 
Introduction to DevOps | Edureka
Introduction to DevOps | EdurekaIntroduction to DevOps | Edureka
Introduction to DevOps | Edureka
 

Recently uploaded

Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*
Frank van Harmelen
 
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Product School
 
Knowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and backKnowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and back
Elena Simperl
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
Prayukth K V
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
DanBrown980551
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
UiPathCommunity
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance
 
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
Product School
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
Guy Korland
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
Safe Software
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
Ana-Maria Mihalceanu
 
JMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and GrafanaJMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and Grafana
RTTS
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
Alan Dix
 
Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
OnBoard
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
DianaGray10
 
Connector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonConnector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a button
DianaGray10
 
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Product School
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
KatiaHIMEUR1
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
BookNet Canada
 

Recently uploaded (20)

Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*
 
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
 
Knowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and backKnowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and back
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
 
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
 
JMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and GrafanaJMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and Grafana
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
 
Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
 
Connector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonConnector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a button
 
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
 

Principles of MVC for Rails Developers

  • 1. Principles of MVC For rails Developers View Ruby On Rails Course at: www.edureka.co/ruby-on-rails For more details please contact us: US : 1800 275 9730 (toll free) INDIA : +91 88808 62004 Email Us : webinars@edureka.co For Queries: Post on Twitter @edurekaIN: #askEdureka Post on Facebook /edurekaIN
  • 2. Slide 2 www.edureka.co/ruby-on-rails Objectives At the end of this module, you will be able to understand:  Challenges Faced when Designing an Application Without Framework  MCV Design Patterns  Logic Behind MVC  DRY and Convention Over Configuration  MVC Benefits  Demo on MVC in RAILS
  • 3. Slide 3 www.edureka.co/ruby-on-rails Challenges Faced when Designing an Application without a Framework  Complexity in direct coding  Everything must be tested, which is difficult  Difficult to re-use code  Hard code everything from scratch  Teamwork challenges - parallel programming cannot be done efficiently
  • 4. Slide 4 www.edureka.co/ruby-on-rails  Leads to disorganization  Change one thing, break another Challenges Faced when Designing an Application without a Framework
  • 5. Slide 5 www.edureka.co/ruby-on-rails The Solution is to use Design Patterns Design Patterns is the way to organize a program in a proper manner One such design pattern is MVC
  • 6. Slide 6 www.edureka.co/ruby-on-rails Introduction – What is MVC MVC Introduction MVC is acronym for Model-View-Controller A software design pattern for developing web and desktop applications In simple words, a better way of separating the logic of your application from the display.
  • 7. Slide 7 www.edureka.co/ruby-on-rails  Originally described in terms of a design pattern for use with Smalltalk by Trygve Reenskaug in 1979.  His paper was published under the title "Applications Programming in Smalltalk-80: How to use Model-View- Controller", and paved the groundwork for most future MVC implementations.  MVC design pattern is used to separate an application’s data, business logic, and presentation; doing so facilitates the creation of more maintainable, reusable, and testable code. • Model - Data Layer • View - User Interface Layer • Controller - Interacts with the Model MVC Introduction
  • 8. Slide 8 www.edureka.co/ruby-on-rails MVC - Illustration Web Browser/Client HTTP Request HTTP Response CONTROLLER MODEL VIEW Data object Request Data Objects Response Render dataEvents (GET/POST) Handled by Framework (Hidden from user) Database Database Request Raw Data Response MVC Container Website User http://www.mywebsite.com
  • 9. Slide 9 www.edureka.co/ruby-on-rails Model Data access routines and some business logic can be defined in the model. Model is responsible for providing the data from the database and saving the data into the data store. Models are active representations of database tables: they can connect to your database, query it (if instructed to do so by a controller) and save data to the database. No interaction between models and views: all the logic is handled by controllers. MVC - Data Layer
  • 10. Slide 10 www.edureka.co/ruby-on-rails View Views define exactly what is presented to the user. It collects data from the user and gives it to controller and controller invokes the required model. Controllers pass data to each view to render in some format. Views can be described as template files that present their content to the user: variables, arrays and objects that are used in views are registered through a controller. Views should not contain complex business logic; only the elementary control structures necessary to perform particular operations, such as the iteration of collected data through a foreach construct, should be contained within a view. MVC - User Interface Layer
  • 11. Slide 11 www.edureka.co/ruby-on-rails Controller Controllers bind the whole pattern together. Controller is intermediary between View and Model. Controllers contain the logic of your application. Each controller can offer different functionality; controllers retrieve and modify data by accessing database tables through models; and they register variables and objects, which can be used in views. Once request is received from client it executes the appropriate business logic from the model, decide which view to display based on the user's request and other factors, pass along the data that each view will need, or hand off control to another controller entirely. MVC - Interacting With Model
  • 12. Slide 12 www.edureka.co/ruby-on-rails DRY  DRY just means "Don't Repeat Yourself". Make sure that when you write code, you only write it one time.  The DRY principle is stated as "Every piece of knowledge must have a single, unambiguous, authoritative representation within a system." Reference: https://maurits.wordpress.com
  • 13. Slide 13 www.edureka.co/ruby-on-rails Convention Over Configuration  Convention over configuration (also known as coding by convention) is a software design paradigm which seeks to :  For example, if there is a class Sale in the model, the corresponding table in the database is called "sales" by default. It is only if one deviates from this convention, such as calling the table "product sales", that one needs to write code regarding these names. Not losing flexibility Decrease number of decisions on developers Gain Simplicity
  • 15. Slide 15 www.edureka.co/ruby-on-rails  Rails application can be created using the following command >rails new app_name  When you create an application using the rails helper script, you can see that a new directly structure is created for your application. The directory structure will have to following directories that will be explained in the next slide. Creating a Rails Application
  • 16. Slide 16 www.edureka.co/ruby-on-rails Directory Layout File /Folder Purpose app/ Contains the controllers, models, views, helpers, mailers and assets for your application. bin/ Contains the rails script that starts your app and can contain other scripts you use to deploy or run your application. config/ Configure your application's routes, database, and more condig.ru Rack configuration for Rack based servers used to start the application. db/ Contains your current database schema, as well as the database migrations Gemfile Gemfile.lock These files allow you to specify what gem dependencies are needed for your Rails application. These files are used by the Bundler gem. Lib/ Extended modules for you application Log/ Application log files
  • 17. Slide 17 www.edureka.co/ruby-on-rails Directory Layout (Contd.) File /Folder Purpose public/ The only folder seen by the world as-is. Contains static files and compiled assets. Rakefile This file locates and loads tasks that can be run from the command line. Rather than changing Rakefile, you should add your own tasks by adding files to the lib/tasks directory of your application README.rdoc This is a brief instruction manual for your application. You should edit this file to tell others what your application does, how to set it up, and so on. test/ Unit tests, fixtures, and other test apparatus. tmp/ Temporary files (like cache, pid, and session files). Vendor/ A place for all third-party code. In a typical Rails application this includes vendor’s gems.
  • 18. Slide 18 www.edureka.co/ruby-on-rails  Rails application can be booted using the following command >rails server  This command will fire up WEBrick, a web server distributed with Ruby. » Default environment is development » Default port is 3000 » http://127.0.0.1:3000 Running Rails Application
  • 19. Slide 19 www.edureka.co/ruby-on-rails To see your application in action, open a browser window and navigate to http://localhost:3000 Running Rails Application (Contd.)
  • 21. Questions Slide 21 www.edureka.co/ruby-on-railsTwitter @edurekaIN, Facebook /edurekaIN, use #AskEdureka for Questions