Reputation: 7941
I'm trying to include Facebook Comments in my app (Rails4).
The Div for the comments is
<div class="fb-comments" data-href="{URL_HERE}" data-width="570"></div>
where {URL_HERE} i need
request.original_url
or the url of the current page.
How can i set this up ?
I tried
<div class="fb-comments" data-href="#{request.original_url}" data-width="570"></div>
But i'm getting a error from facebook
Upvotes: 1
Views: 435
Reputation: 7941
OK, i got it. Didn't need to use interpolation here.
<%= request.original_url %>
For anyone who stumbles upon this:
For Rails 3.2 or Rails 4 you should use request.original_url
to get the current URL. More detail.
For Rails 3: You want "#{request.protocol}#{request.host_with_port}#{request.fullpath}"
, since request.url
is now deprecated.
For Rails 2: You want request.url
instead of request.request_uri
. This combines the protocol (usually http://) with the host, and request_uri to give you the full address.
Upvotes: 2