Sunday, April 4, 2010

Workshop 5 - Part A

This particular Workshop gives us the choice to either carry on the role as a developer or swap to being an IT infrastructure manager. I have chosen to carry on the role as a developer as i am finding the use of Ruby on Rails to be quite interesting and useful to my current career.

Part A: View the action


1. Create the Rails application framework in the projects folder: C:\InstantRails\...\projects\>rails animals



















2. Running the application on localhost:3000 using the WeBrick ruby server (or Mongrel as alternative) and access via Web browser at http://localhost:3000/




















3. Create the controller to make the application do an action. This is under the controller-action/model-view structure.
















4. Test the controller by starting the WEBrick server and navaigatibng the browser to http://localhost:3000/mammal Note how the controller name is appended to the end of the URL and that no action resulted because there are no controller methods.









5. Create an ac
tion by editing and saving the mammal_controller.rb class in projects\animals\app\controllers using your text editor to add the method below:

6. Start the WEBrick server and browse at http://localhost:3000/mammals/breathe where you will get a “missing template” message since it is missing a view for the breathe method.










7. Create and save a view in that directory by using a text editor to create a view called breathe.rhtml
































(The output to the webpage for the Inhale and Exhale)

8. Try Ruby code and HTML in the action view by using the <%....%> wrapper around the inserted Ruby code. Here are some snippets to try from workshop 4:

No comments:

Post a Comment