Full URL with url_for in Rails

ruby-on-rails

Solution

Use the :host option. For example, you can use:

url_for(@book, :host => "domain.com")

Note: with Rails 3 and above, use `polymorphic_url` instead of `url_for`.

Problem

How can I get a full url in rails? url_for @book is returning only a path like /book/1 and not www.domain.com/book/1 Thanks (and sorry if the answer is obvious. Im learning rails!)

Original source