1

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

enter image description here

Mini John
  • 7,855
  • 9
  • 59
  • 108

1 Answers1

2

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.

Community
  • 1
  • 1
Mini John
  • 7,855
  • 9
  • 59
  • 108
  • can you please help me am also facing same problem.http://stackoverflow.com/questions/22879718/ruby-on-rails-how-to-get-current-page-url/22879734?noredirect=1# – XYZ_deve Apr 05 '14 at 11:35