Eric Goodwin

archive

Automatic Body Tag with ID and Class
05/10/09

When I first started coding for Rails I came across a post written by Ryan of fivesevensix.com describing how to automate the naming of your body id tag. Since then I’ve been using his tecnique with a slight twist. Here is my variation.

This code goes in your application controller.

1
2
3
4
5
def body_tag
    idname = controller.class.to_s.underscore.gsub(/_controller$/, '')
    classname = controller.action_name.underscore
    "<body id=\"#{idname}\" class=\"#{classname}\">"
end

And this code replaces the body tag in your template rhtml files.


<%= body_tag %>

The only difference between Ryan’s code and mine is that he puts both the controller name and the action name in the id, and I put the controller name in the id and the action name in the class. I find that this small change allows for a bit more flexability when writing the css.

1 comment

It Came in Through the Bathroom Window
05/10/05

Or perhaps the front door, I’m not too sure. All I know is that when I arrived home yesterday my new book was waiting for me infront of my computer.
Agile Web Development with Rails

0 comments

Hosting Craziness
05/10/04

Although I host my blog with Textdrive now, I have quite a few other domains still over at Dreamhost. Since I’ve been using Dreamhost the only problem I’ve ever come across was Typo, other than that everything else has ran very well. So … I hate to make a plug for a company but I just recieved an email the other day detailing changes to their hosting plans. Here is a summary:

Unlimited Domains Hosted, Diskspace Doubled, Unlimited Mysql Databases, Ruby On Rails

And to top it all off they are having a 80% off sale at the moment.

6 comments

After a weekend of work
05/10/03

This past weekend I spent some time creating a small web app. It’s still in it’s infancy but as soon as it’s ready I’ll put it out there for anyone who’s interested. Here are a couple clues and a sneak peak.

iTunes, Rails, XSLT, Flash, Javascript, MySQL

2 comments

About

Eric Goodwin is a web developer living in Victoria BC, Canada. You can contact him at eric@ericgoodwin.com

Open Source

Projects

Elsewhere

Archives