Restart the Web server and navigate the browser to http://localhost:3000/demo/rubycode
Data has been passed from the action to the view as it is done with SQL requests. The instance variables of a Ruby class are available to view templates by referencing the action’s instance variables by name in the view .rhtml template.
Showing posts with label Workshop 5 - To do (Red team) Part B. Show all posts
Showing posts with label Workshop 5 - To do (Red team) Part B. Show all posts
Saturday, April 18, 2009
Workshop 5: Admiring the secenery Forms, AJAX screen layout and and mobile interfraces: To Do (RED team) Part B The active view: passing data 8.:
Then modify and save the corresponding view template in \app\views\demo\rubycode.rhtml by adding a call by reference to the action’s instance variable:
Workshop 5: Admiring the secenery Forms, AJAX screen layout and and mobile interfraces: To Do (RED team) Part B The active view: passing data 7.:
Modify and save the rubycode action with a value for the time instance variable in the DemoController class in app\controllers\demo_controller.rb
class DemoController< ApplicationController
def rubycode
@time_now = Time.now
end
end
class DemoController< ApplicationController
def rubycode
@time_now = Time.now
end
end
Workshop 5: Admiring the secenery Forms, AJAX screen layout and and mobile interfraces: To Do (RED team) Part B The active view: passing data 6.:
Use the Time.now example to pass data from an action to a view.
Workshop 5: Admiring the secenery Forms, AJAX screen layout and and mobile interfraces: To Do (RED team) Part B The active view: passing data 5.:
Save and restart the Web server and navigate to http://localhost:3000/scenery/rubycode
Workshop 5: Admiring the secenery Forms, AJAX screen layout and and mobile interfraces: To Do (RED team) Part B The active view: passing data 4.:
Add a view template - scenery\app\views\demo\rubycode.rhtml
We will edit this view in later steps but you may like to add your own test HTML code to the view at this stage.
We will edit this view in later steps but you may like to add your own test HTML code to the view at this stage.
Workshop 5: Admiring the secenery Forms, AJAX screen layout and and mobile interfraces: To Do (RED team) Part B The active view: passing data 3.:
Add an action to demo_controller.rb as the method called rubycobe
class DemoController< ApplicationController
def rubycode
end
end
class DemoController< ApplicationController
def rubycode
end
end
Workshop 5: Admiring the secenery Forms, AJAX screen layout and and mobile interfraces: To Do (RED team) Part B The active view: passing data 2.:
Create a controller called Demo in scenery\app\controllers
scenery> ruby script/generate controller Demo
scenery> ruby script/generate controller Demo
Workshop 5: Admiring the secenery Forms, AJAX screen layout and and mobile interfraces: To Do (RED team) Part B The active view: passing data 1.:
Create a new application called scenery in the same projects directory to demonstrate the use of an active view.
> rails scenery
> cd scenery
> rails scenery
> cd scenery
Subscribe to:
Posts (Atom)