user1919937 user1919937 - 1 year ago 174
Ruby Question

Add Class To Body Using ERB In A View - Rails

I've watched this screencast to add a page title when in a view, is there a way I can do the same but add a class the body tag?

Answer Source

Not sure what you mean, you can do it the same way:

In a view:

<% content_for :body_class, "my_class" %>

In a layout file:

<body class="<%= yield (:body_class) %>">
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download