Notes posted by tomharrisonjr
RSS feedSpecify :host option in emails
Emails need a fully qualified URL (with domain). Use the :host parameter.
But note also that you need to specify a value that is not dependent upon the request context. http://api.rubyonrails.org/classes/ActionMailer/Base.html recommends setting a default host in application.rb For those of us who have development, test, staging and production environments, set in the environment-specific files, or in the :default hash in the mailer.
This applies to both +url_for(:host => “example.com”)+ and when using named routes as in +widgets_url(:host => “example.com”)+
HTML5 data- attributes using RESTful approach
HTML5 specifies extensible attributes like data-foo=“bar” (or as in Twitter Bootstrap data-toggle=“modal”), which poses two problems for Rails.
First, if you’re using symbol notation in link_to to specify attributes, this fails (dash is not a valid symbol character), so
Invalid!
link_to "Edit", @user, :class => "btn", :data-toggle => "modal"
There are two solutions:
-
put the symbols in quotes,
-
use the special :data hash
Solution 1: Quote Symbols
link_to "Edit", @user, :class => "btn", "data-toggle" => "modal"
Solution 2: Use the :data hash
link_to "Edit", @user, :class => "btn", :data => {:toggle => "modal"}
Resulting HTML
<a href="/users/1" class="btn", data-toggle="modal">Edit</a>
The second is minimally documented, but as a hash, can accept multiple values and is perhaps a little cleaner