12.3.11

Ruby Rails and our Chapter Two assignment

Categories:

I've got everything to work..... Rails is up and running, the server seems to be behaving himself, I've created two web pages that link to each other, and on one of the web pages I've embedded some ruby that does some nifty stuff like tell us what time it is now, list all the documents in a directory, do some simple calculations, tell us what time it will be from an hour from now, and it also adds some simple strings to-gether.  So happy days!  But along the way I've strayed a little from the instructions in the book.

First thing I noticed that the root :to => "say#hello" in routes.rb worked fine once there was only 1 webpage, and once you were only using the url localhost:3000.  Once I specified the whole webpage I got an error saying "something I didn'nt record".  So after some googling I decided to add the following to routes.rb  
do
  match ':controller(/:action(/:id(.:format)))'
  end
and that seems to work well as long as you specify the full url, but not the root.
So I carried on, and tried to get the links between the hello view and goodbye view working, which again wasn't happy to play.   So I found the following code from google

<p><%= link_to "Goodbye", :action => 'goodbye' %></p> 

and once I copied and pasted into  view/hello it all seemed to work fine. My limited grasp on what's happening here, is that the controller and the view weren't talking properly to each other, and that the file route.rb is the glue that can make it all happen.  According to the book it should happen automatically, but for some reason it's not and I needed to specify within the view html.erb file where it should look.  It's working now, I completed the exercise, but I'm worried that the spurious code I've  added will come back to bite me.

Spread The Love, Share Our Article

Related Posts

No Response to "Ruby Rails and our Chapter Two assignment"

Post a Comment