
- Isolation of business logic from the user interface
- Ease of keeping code DRY
- Making it clear where different types of code belong for easier maintenance
1) Model
A model represents the information (data) of the application and the rules to manipulate that data. In the case of Rails, models are primarily used for managing the rules of interaction with a corresponding database table. In most cases, one table in your database will correspond to one model in your application. The bulk of your application’s business logic will be concentrated in the models.
2) View
The view renders the model into a form suitable for interaction, typically a user interface element. Multiple views can exist for a single model for different purposes. A viewport typically has a one to one correspondence with a display surface and knows how to render to it.
3) Controller
The controller receives input and initiates a response by making calls on model objects. A controller accepts input from the user and instructs the model and viewport to perform actions based on that input.
So the steps involved in the working of MVC is as follows
- The browser makes a request, such as http://rubyonrailslink.blogspot.com/2010/09/what-is-rails.html
- web server (mongrel, WEBrick, etc.) receives the request. It uses routes to find out which controller to use: the default route pattern is “/controller/action/id” as defined in
config/routes.rb
. In our case, it’s the “video” controller, method “show”, id “15″. The web server then uses the dispatcher to create a new controller, call the action and pass the parameters.
- Controllers do the work of parsing user requests, data submissions, cookies, sessions and the “browser stuff”. They’re the pointy-haired manager that orders employees around. It gives orders without knowing (or caring) how it gets done. In our case, the show method in the video controller knows it needs to lookup a video. It asks the model to get video 15, and will eventually display it to the user.
- Models are Ruby classes. They talk to the database, store and validate data, perform the business logic and otherwise do the heavy lifting. In this case, the model retrieves video 15 from the database.
- Views are what the user sees: HTML, CSS, XML, Javascript, JSON. They’re the sales rep putting up flyers and collecting surveys, at the manager’s direction. Views are merely puppets reading what the controller gives them. They don’t know what exactly happening in the back room. In our example, the controller gives video 15 to the “show” view. The show view generates the HTML: divs, tables, text, descriptions, footers, etc.
- The controller returns the response body (HTML, XML, etc.) & metadata (caching headers, redirects) to the server. The server combines the raw data into a proper HTTP response and sends it to the user.
superb daa keep posting valuable info
ReplyDeleteMVC is popular because it isolates the application logic from the user interface layer and supports separation of concerns. The controller receives all requests for the application and then works with the model to prepare any data needed by the view. The view then uses the data prepared by the controller to generate a final presentable response. AngularJS Training in Chennai
ReplyDeleteGiven so much info in it, These type of articles keeps the users interest in the website, and keep on sharing more ..Best Angularjs Training in Chennai|Angularjs Training in Chennai
ReplyDeleteI appreciate your blog ,Very Nice
ReplyDelete.Net Online Course Hyderabad
Thanks a lot for sharing such a good source with all, i appreciate your efforts taken for the same. I found this worth sharing and must share this with all.
ReplyDeleteDot Net Training in Chennai | Dot Net Training in anna nagar | Dot Net Training in omr | Dot Net Training in porur | Dot Net Training in tambaram | Dot Net Training in velachery
Thanks for sharing a valuable topic in this Blog Really it is very helpful and interesting. All the best and do share such articles in future also.
ReplyDeleteDigital Marketing Training in Chennai
Digital Marketing Course in Chennai
adana escort - adıyaman escort - afyon escort - aksaray escort - antalya escort - aydın escort - balıkesir escort - batman escort - bitlis escort - burdur escort - bursa escort - diyarbakır escort - edirne escort - erzurum escort - eskişehir escort - eskişehir escort - eskişehir escort - eskişehir escort - gaziantep escort - gebze escort - giresun escort - hatay escort - ısparta escort - karabük escort - kastamonu escort - kayseri escort - kilis escort - kocaeli escort - konya escort - kütahya escort - malatya escort - manisa escort - maraş escort - mardin escort - mersin escort - muğla escort - niğde escort - ordu escort - osmaniye escort - sakarya escort - samsun escort - siirt escort - sincan escort - tekirdağ escort - tokat escort - uşak escort - van escort - yalova escort - yozgat escort - urfa escort - zonguldak escort
ReplyDeletehttps://www.escortsmate.com - adana escort - adıyaman escort - afyon escort - ağrı escort - aksaray escort - amasya escort - ankara escort - antalya escort - ardahan escort - artvin escort - aydın escort - balıkesir escort - bartın escort - batman escort - bayburt escort - bilecik escort - bingöl escort - bitlis escort - bolu escort - burdur escort - bursa escort - çanakkale escort - çankırı escort - çorum escort - denizli escort - diyarbakır escort - düzce escort - edirne escort - elazığ escort - erzincan escort - erzurum escort - eskişehir escort - gaziantep escort - gebze escort - giresun escort - gümüşhane escort - hakkari escort - hatay escort - ığdır escort - ısparta escort - izmir escort - istanbul escort - karabük escort - karaman escort - kars escort
ReplyDeletebitcoin nasıl alınır
ReplyDeletetiktok jeton hilesi
youtube abone satın al
gate io güvenilir mi
binance referans kimliği nedir
tiktok takipçi satın al
bitcoin nasıl alınır
mobil ödeme bozdurma
mobil ödeme bozdurma
SMM PANEL
ReplyDeletesmm panel
iş ilanları
instagram takipçi satın al
hirdavatciburada.com
BEYAZESYATEKNİKSERVİSİ.COM.TR
servis
tiktok jeton hilesi