Skip to content

{ Category Archives } Rails

HOWTO: Getting a sidebar in Merb

In several of my pages, I have a side-bar menu-y thingie. I didn’t want to have to rewrite a controller-specific layout each time, but luckily Merb supports something similar to Rails’s content_for block that I wrote about earlier. In Merb, its done using throw_content(API) and catch_content(API).

Put the catch_content into your application layout view. You probably [...]

Tagged , ,

Rails Logging to Syslog using Logging gem

When using a mongrel cluster, you can either log to a separate file for each mongrel instance, or you can log them all to the same file, but on a loaded cluster, there’s a good chance your logged lines will get interleaved and be unreadable. Luckily, there’s another way. The new replacement for log4r Logging [...]

Tagged

Rails tip: Additional content for a layout

If you need to add additional content to your layout, you can have named content_for blocks. Great for including additional page-specific javascript files.

In application.erb:

Then inside your view, you can:

Tagged ,

Rails update_attribute gotcha

Model#update_attribute(:name, “Rando”) does not trigger any validations, even on name and just saves it to the database.

Model#update_attributes(:name => “Rando”) does run all validations, and returns false if they fail.

Rails docs

Tagged ,