Model-View-Controller ( Rails view )

Model-View-Controller ( Rails view )
. A controller have many actions in it and each action has a cooresponding view to it.
(Eg. if a rails app have a controller named book_controller and two actions in it , one to ‘list’ and other to ‘save’ new book to the list , then it will have a folder book in view and we have to write ‘list.rhtml’ and ‘save.rhtml’ in it.
. Controller fetches all those data necessary for view to render the user view from the database using models, or we can say controllers deals most of the database manipulations like -> find, new, create, save etc.
.MVC Framework archeitecture , Controllers are executed first and the result is rendered through the view file,also view can send data to its own controllers too…(eg: in rails if statement with! as condition).
. If a user input has to be passed onto a controller, it has to be passed from its previous view using API’s like -> link_to , form_tag etc. and we catch those inputs using params[:parameter-var-name] , a hash internal datastructure.
. Mostly database activities are hidden from the view file and thus the final html source code, as it is executed only at the server side in controller-actions and outputs are saved onto the variables for use in its view ( make sure to call the variables as private as else it may interfere the correctness of data on multiple user requests. )


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s