In iPhone OS 3.0, Apple allowed Mobile Safari to save usernames and passwords in web forms. Unfortunately, Safari does not offer to do the same thing for HTTP Basic and Digest authentication. I’ve become fond of using HTTP authentication because it is very easy to set up, either in your Apache virtual host configuration or within a Rails application. There are many times that a full-fledged user database is unnecessary for a simple administration back-end.
There is a work-around, though it does mean storing your user and password in plaintext in your device’s bookmarks. HTTP allows you to supply authentication credentials as part of the URL, in the form http://username:firstname.lastname@example.org/.
Here is a useful trick for ensuring that you keep your partial templates well organized without sacrificing page-load times or duplicating your layouts unnecessarily.
You can use content_for to capture some markup, but have it emitted into the page from somewhere else.
content_for works by capturing whatever appears inside the block and storing it for later use. You emit whatever is stored using yield. What’s more, content_for doesn’t clobber the previous captured text if you use it more than once with the same key.
And then in your layout, just before the </body>:
<%= yield :body_close %>
<% content_for :head do %> <%= stylesheet_link_tag 'fancy_control' %> <% end %>
And in your layout:
<head> ... <%= yield :head %> </head>
This is also useful for keeping per-page markup like <title> and meta tags in the template and out of your controller.