Topic: Mysql method escape string in rails

Using the Ruby Mysql database connector there is a method called escape_string which, go figure, takes a string and escapes all of the mysql primitive charactors in it.  Is there an equivilant in rails, or a way to access the mysql connection variable?

If art interprets our dreams, the computer executes them in the guise of programs.

-SICP (Abelson, Sussman)

Re: Mysql method escape string in rails

Try the "sanitize" class method on a model:

Person.sanitize(str)

I usually use this inside a class method in a model so you don't need to specify the class in front of it. I think quote() class method does the same thing.

One thing to keep in mind is that these two methods will automatically quote the string (with single quotes).

Railscasts - Free Ruby on Rails Screencasts

Re: Mysql method escape string in rails

Thanks a lot for cutting through arcania for me, I've been searching for that for a while.

If art interprets our dreams, the computer executes them in the guise of programs.

-SICP (Abelson, Sussman)