Quantcast
Channel: Roommate App Development Blog
Viewing all articles
Browse latest Browse all 10

RESTful CSS Update

$
0
0

Quick update pertaining to RESTful CSS, a method for organizing CSS I wrote a little while ago.

I created a few extra helpers for the body tag. I’ve been adding IDs and classes to the body tag in the form of id=”controller_action” class=”controller action”, so I created these methods to both clean up the html, and to add the extra functionality of overwriting “create” with “new”, and “update” with “edit”. This is needed because of the way Rails handle form errors. Here are the methods.

def body_id
controller.controller_name + "_" + { "create" => "new", "update" => "edit" }[controller.action_name] || controller.action_name
end

def body_class
controller.controller_name + " " + { "create" => "new", "update" => "edit" }[controller.action_name] || controller.action_name
end

The body tag would then look like:

<body id="<%= body_id %>" class="<%= body_class %>">


Viewing all articles
Browse latest Browse all 10

Trending Articles