Shamith c
Shamith c

Reputation: 3739

Escape ( ' ) in Ruby On Rails

I am using return url to facebook in ROR as

  <fb:login-button length="long" onlogin='location.href = "<%= check_url %>?id=<%= @a %>"' scope="publish_stream" >Post to my Wall</fb:login-button>

here @a is dynamic variable, It is large string more than 10 character. eg:-

case 1:- @a= You have the power to influence all with whom you come in contact. 
case 2:- @=You'll never be the man your mother was!

case 1 is Working But case 2 is not because of (') .How to escape this (').

Upvotes: 0

Views: 128

Answers (1)

rubyprince
rubyprince

Reputation: 17803

Use CGI::escape() to URL encode the variable before passing as a parameter to the url like this: 'location.href = "<%= check_url %>?id=<%= CGI::escape(@a) %>"'

Upvotes: 2

Related Questions