Full URL with url_for in Rails

前端 未结 6 1575
别那么骄傲
别那么骄傲 2020-12-28 15:34

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 obvio

6条回答
  •  佛祖请我去吃肉
    2020-12-28 16:10

    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.

提交回复
热议问题