CSC/ECE 517 Fall 2012/ch1b 1w64 nn: Difference between revisions

From Expertiza_Wiki
Jump to navigation Jump to search
Line 1: Line 1:
==SaaS - 3.12 Controller and views==
==SaaS - 3.12 Controller and views==
===Introduction===
===Introduction===
===Adding new action in Rails===
===Adding a new controller action to Rails application===
#
* Route: Make sure that there is a route that is going to eventually route action, if not create one in routes.rb.
#
* You have to add the actual code in other words, the method in the appropriate control file that will do whatever that action is.
#
* You have to assure that there is something to the action can render what its all done. Every trip through the controller has to end with returning something and will see that although the most common thing is returning a view whose name matches the controller action, we can also return other things.
===MVC responsibilities===
===MVC responsibilities===
*Model
*Model

Revision as of 02:34, 29 September 2012

SaaS - 3.12 Controller and views

Introduction

Adding a new controller action to Rails application

  • Route: Make sure that there is a route that is going to eventually route action, if not create one in routes.rb.
  • You have to add the actual code in other words, the method in the appropriate control file that will do whatever that action is.
  • You have to assure that there is something to the action can render what its all done. Every trip through the controller has to end with returning something and will see that although the most common thing is returning a view whose name matches the controller action, we can also return other things.

MVC responsibilities

  • Model
  • Controller
def show
  @movie = Movie.find(params[:id])
end
  • View

URI helpers

References