Friday, 17 April 2015

Absolute URL / Full URL in Rails 4

Rails 4


def absolute_url
  request.base_url + request.original_fullpath

Action Mailer Notable changes in 4.2 release:

  • link_to and url_for generate absolute URLs by default in templates, it is no longer needed to pass only_path: false. (Commit)

If you use the _url suffix, the generated URL is absolute. Use _path to get a relative URL.

<%= link_to "User Home", user_url %>

No comments:

Post a Comment