Search code examples
ruby-on-railsfacebookruby-on-rails-4facebook-sharer

How to supply current url in Facebook share link


I'm trying to make a Share on Facebook link with the following code:

<%= link_to 'Share on Facebook', 'https://www.facebook.com/dialog/share?
  app_id=xxxxxxxxxxxxxx&href=#{request.original_url}&redirect_uri=#{request.original_url}' %>

Needless to say the href and uri links don't get supplied. How can I insert the rails term request.original_url into this link?

Is it possible?


Solution

  • Change your code into :

    <%= link_to 'Share on Facebook', "https://www.facebook.com/dialog/share?
      app_id=xxxxxxxxxxxxxx&href=#{request.original_url}&redirect_uri=#{request.original_url}" %>