user1919937 user1919937 - 8 months ago 107
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?


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) %>">