So I just wanted to display
Shop.all.to_sql
as
=> "SELECT "shops".* FROM "shops""
but got
=> "SELECT \"shops\".* FROM \"shops\""
I tried gsub, but rails ignores '\'
Shop.all.to_sql.gsub('\', '')
How could I get rid of '\'?
Those \
are not really there - this is way ruby displays strings (or rather this is the way inspect
method works for strings). In short, it is to say that the next "
is not the end of the string but rather a part of it:
'"' #=> "\""
To see there are no slashes, tell ruby to display the resulting strings:
puts Shop.all.to_sql
# SELECT "shops".* FROM "shops"
#=> nil
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With