Uday kumar das Uday kumar das - 2 years ago 130
Ruby Question

remove `\"` from string rails 4

I have params like:

params[:id]= "\"ebfd11a9-3aa4-415a-ba72-1b6796ea1bf6\""

And i want to get expected result as below:


How can I do this?

Answer Source

You can use gsub:

"\"ebfd11a9-3aa4-415a-ba72-1b6796ea1bf6\"".gsub("\"", "")
=> "ebfd11a9-3aa4-415a-ba72-1b6796ea1bf6"

Or, as @Stefan mentioned, delete:

=> "ebfd11a9-3aa4-415a-ba72-1b6796ea1bf6"
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download