On 10-10-20 06:33 AM, Murph2m wrote:
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...
On Oct 20, 11:16 am, Rajinder Yadav<[email protected]> wrote:
On 10-10-20 06:13 AM, Rajinder Yadav wrote:
On 10-10-20 05:18 AM, Murph2m wrote:
Ok - Thanks so I was reading it wrong! but then all that is in the
pages_controller.rb is:
class PagesController< ApplicationController
def home
@title = "Home"
end
def contact
@title = "Contact"
end
def about
@title = "About"
end
def help
@title = "Help"
end
end
Doesn't this just define some variables? what is the action?
the action are defined as ruby method using 'def/end' blocks: here the
defined actions are obviously: home, contact, about and help
yes each action assigns a value to a variable, you'll see other examples
where real actions are defined later on! one step at a time =)
rails follows convention over configuration, read my last email and go
over MVC in the tutorial, page 1
http://railstutorial.org/chapters/beginning#sec:mvc
http://railstutorial.org/chapters/a-demo-app#sec:mvc_in_action
basically rails know what view to call based on the action by using the
same name as the action! this is the rails convention (way of doing
things!).
--
Kind Regards,
Rajinder Yadav | DevMentor.org | Do Good! ~ Share Freely
GNU/Linux: 2.6.35-22-generic
Kubuntu x86_64 10.10 | KDE 4.5.1
Ruby 1.9.2p0 | Rails 3.0.1
--
You received this message because you are subscribed to the Google Groups "Ruby on
Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.