I’d either never picked up on this or totally forgotten it, but I ran across it while reading Ajax on Rails:
If you create a layout file under app/views/layouts/ called application.rhtml, Rails will pick that up as a default layout for your entire application, assuming you haven’t created other layouts already.
By default Rails looks first for a layout template with the same name as the current controller with the extension .rhtml. If it can’t find this layout, it goes looking for application.rhtml layout.
Somehow, I’d gotten in the habit of creating a layout called default.rhtml, and specifying that my controllers use it. Oops. Don’t I feel rather daft now.
This isn’t the first time I’ve come across a little tip like this in Ajax on Rails. I’ll try to remember to blog the others. In the meantime, pick up a copy for yourself.
Tags: books · Rails · tipsNo Comments


0 responses so far ↓
There are no comments yet...Kick things off by filling out the form below.