Using Application.rhtml as layout for all controllers

I put my nav system in application layout. that way any controller
loading will have the nav system. I have one problem though - the <%=
yield %> is in the body, so how would my controllers specify other css
files?

my application layout would look like this:

title css include javascript include nav system <%=yield%>

so that means any controllers go into the body immediatly - so can they
not have their own css files without specifying them in application
layout?

Thanks,
Ben L.

On 7/19/06, Ben L. [email protected] wrote:

I put my nav system in application layout. that way any controller
loading will have the nav system. I have one problem though - the <%=
yield %> is in the body, so how would my controllers specify other css
files?

Check out the Cascading Stylesheets Plugin:
http://www.redhillconsulting.com.au/rails_plugins.html#cascading_stylesheets

It will let you have a seperate style sheet for application ->
controller ->
action

Josh

Ripped off from a post yesterday (Credit to Richard L.), this may
help…

Take a look at:

http://api.rubyonrails.com/classes/ActionView/Helpers/CaptureHelper.html

Specifically:

In your layout:

... stuff <%= @content_for_head %>

In your template:

<% content_for(“head”) do %>
the javascript / include js file
<% end %>

Josh K. wrote:

On 7/19/06, Ben L. [email protected] wrote:

I put my nav system in application layout. that way any controller
loading will have the nav system. I have one problem though - the <%=
yield %> is in the body, so how would my controllers specify other css
files?

Check out the Cascading Stylesheets Plugin:
http://www.redhillconsulting.com.au/rails_plugins.html#cascading_stylesheets

It will let you have a seperate style sheet for application ->
controller ->
action

Josh

awesome thanks Josh!

-Ben L.

Hello Ben,

I put my nav system in application layout. that way any controller
loading will have the nav system. I have one problem though - the <%=
yield %> is in the body, so how would my controllers specify other css
files?

You can specify parts of code that will be used in layout, like with
yield /
@content_for_layout system.

yield :foo is the same as @content_for_foo, but the first syntax
is now preferred.

my application layout would look like this:

title css include javascript include

here put a <%= yield :specific_css %> for example.

nav system <%=yield%>

And in your view :

<% content_for :specific_css do -%>
<%= stylesheet_link_tag “foo” %>
other code if you want…
<% end -%>

See
http://api.rubyonrails.org/classes/ActionView/Helpers/CaptureHelper.html#M000528
for further information.

so that means any controllers go into the body immediatly - so can they
not have their own css files without specifying them in application
layout?

РJean-Fran̤ois.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs