Coding

My Rails production setup

Posted in Coding on February 4th, 2009 by erik – 3 Comments

I’ve recently moved one of the products I’m maintaining to a new server, because it wasn’t performing as well as it was supposed to. In the process I’ve spent some time tweaking the server and simplifying the setup, and the following is an overview over some of the tools I’ve found most useful.
read more »

DRY(er) Ruby on Rails view templates

Posted in Coding on May 13th, 2008 by erik – Be the first to comment

Something I keep coming across when working with Ruby on Rails view templates, is wrapping blocks of content in common DIV tags with certain properties, so I can easily style the application with CSS.

For example, a page can have multiple content boxes, and possibly a sidebar with a number of info boxes. What I used to do, was something like this:

<div id="sidebar">
  <div class="infobox">
    Here is some help
  </div>
</div>
<div class="content_box">
	<%= render :partial => "table", :locals => {:people => @people} %>
</div>

Instead, by looking at the implementaton of the content_tag_for ActionView helper, I was able to find a way to do this:

<% sidebar do %>
  <% infobox do %>
    Here is some help
  <% end %>
<% end %>
<% content_box do %>
  <%= render :partial => "table", :locals => {:people => @people} %>
<% end %>

read more »