Ruby on Rails
Saturday, January 13, 2018
On Sunday, 14 January 2018 00:46:39 UTC, Hassan Schroeder wrote:
On Sat, Jan 13, 2018 at 4:18 PM, Robert Phillips
<robert.p...@gmail.com> wrote:
> So, what it is doing is rails is taking its own template then it dumps my template into its <body></body>
Yep, that's the way it works, though "template" is the wrong word.
This: http://guides.rubyonrails.org/layouts_and_rendering.html
may help.
If you want something within the scope of a layout like a title to be
dynamic you can assign the value in your controller and pass it in
as a variable, e.g. <title>@title</title>
Thanks, I can see what was happening now..
Whatever view is displayed, if displays the html from here
.\app\views\layouts\application.html.erb
which specifies a title and some other tags.
And that file says
<body>
<%= yield %>
</body>
And then so when trying to access '/', it went to some specified controller some action, e.g. blah#bleh, then it rendered the application.html.erb file, and inserted within it, the blah\bleh.html.erb file. A fix was to rename application.html.erb
Why is template not an appropriate name.. Isn't any ERB file a template, since you can insert data into it?
Also I notice that when I do root 'application#a' and I have in my application controller def a end, then I http to '/' then it runs the action but it can't find the template.. Is there anywhere that I can put a.html.erb that the rails server would find it? Or does the application controller not have a corresponding template for each action?
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/bb70c7f9-1ed0-4e71-8c35-0f2c64824656%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment