Doesn’t this just define some variables? what is the action?
i assume you’re reading the “ruby on rails tutorial”?, you need to
understand rails MVC conventions, i suggest you reread the early
chapters =)
when a request comes in the controller is loaded and an action is run,
the controller can then request the model to fetch some data, the class
instance variables defined (those defined with @) in the controller are
accessible from the view. rails display the view following a controller
action.
if you browser to ‘http://ocalhost:3000/pages/home’ then the Pages
controller will be loaded and it will call the home action, which will
assign a variable and then display view home.html.erb
–
Kind Regards,
Rajinder Y. | DevMentor.org | Do Good! ~ Share Freely
Thanks I am trying to keep re-reading it till it sinks in but can I
ask then:
def contact @title = “Contact”
end
If this creates ‘contact’ as the action (I understand the instance
variable of @title which can be seen in the view) where is it defining
what that action does or is it simply mapping to the name
‘contact.html.erb’?
In which case how does it know where to find ‘contact.html.erb’ is it
looping back to the ‘routes.db’ and checking the “get pages/contact”?
Your help is really appreciated and I hope that I am close to getting
it…