- Week 11: Action Controller Basics (Action Controllers are the core of a web request in Rails. They are made up of one or more actions that are executed on request and then either render a template or redirect to another action. An action is defined as a public method on the controller, which will automatically be made accessible to the web-server through Rails Routes.
Topics to be covered: What is ActionController?, ActionController classes, Request handling, Parameters, Session & Flash, Rendering, Redirection, Classic problem of user refresh & redirection, Routing (request mapping)) - 5526_rails_controller.zip (Unzip it in a directory of your choice and read lab document from
/rails_controller/index.html to proceed) (4/24/09: Downloaded) - Week 11 Resources
o Basics
+ Action Pack from api.rubyonrails.org
+ ActionController::Base API from api.rubyonrails.org
+ ActionController::Flash API from api.rubyonrails.org
o Routing
+ ActionController::Routing API from api.rubyonrails.org
o Caching
+ ActionController::Caching API from api.rubyonrails.org - Presentation - PDF: 1 slide per page (OR) OpenOffice file (47 pages) (4/27/2009: Done)
- Online Lab document/Change Log (This is the same document you will find in the hands-on lab zip file) (93 pages)
- EXERCISE 0: Start MySQL database server. (p.2)
- EXERCISE 1: Requests and Parameters I (p.2-15)
- (1.0) Open and run "helloworld" sample application (p.2-4)
- (1.1) Observe parameters in development log. (p.4-6)
- (1.2) Modify the controller (p.6-9)
- (1.3) Pass the parameters through URL (p.9-11)
- (1.4) Observe the parameters in development log (p.11-12)
- (1.5) Observe the controller and action parameters (p.12-16) PROBLEM: :action not displayed. The fix was to rename ":action_name" to ":action1_name"
- EXERCISE 2: Request and Parameters II (p.16-34)
- (2.0) Open and run "helloname" sample application project. (p.16-19)
- (2.1)Observe parameters in development log. (p.19-22)
- (2.2) Study how user input data is collected as parameters (p.22-25)
- (2.3) Study how parameters are accessed in the controller (p.25-26)
- (2.4) Add another column to the table through migration (p.26-30)
- (2.5) Modify the code of index.html.erb and respond.html.erb files. (p.30-31)
- (2.6) Run the helloname application. (p.31-33)
- (2.7) Observe the parameters in development log. (p.33-34)
- EXERCISE 3: Session and Flash (p.34-63)
- (3.1) Use session. (p.34-40)
- (3.2) Use ActiveRecordStore to maintain session data (p.40-56)
- (3.3) Use Flash (p.56-63)
- EXERCISE 4: Rendering (p.63-72)
- (4.1) Use render :text (p.64-66)
- (4.2) Use render :action => :respond (p.66-68)
- (4.3) Use render :action => 'respond" (p.68-70)
- (4.4) Use render :template (p.70-72)
- EXERCISE #5: User refresh problem with "render" - Use "redirect_to" (p.72-87)
- (5.1) Observe the problem of using render :action=>'list' when a user press "Refresh" (p.73-80)
- (5.2) Correct the problem by using redirect :action=>'list' instead (p.80-87)
- EXERCISE #6: Routing Basics (p.87-
- (6.1) Use Rails Console (for routing experimentation) (p.87-88)
- (6.2) Named routes (p.88-92)
- Homework
Friday, April 24, 2009
Week 11: Rails Passion Course
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment