How does one preserve the original quotes? The quotes are required when submitting a quoted search string, for example.
Resulting params[:q]:
Note that Rails throws away quotes if the entire string is quoted, as in example2. But in example1, the quotes are preserved since they are interspersed within the string. I need example2 to preserve the quotes so I see params[:q] as "\\"new york\\"".
Are you talking about sql injectioning you want to search using "test me"
and not "\\"test me"\\"
.
Use following to search
@users = User.find(:all, :conditions=>["(username like :text)",{:text=>"%#{params[:search_text]}%"}])
这是一个已修复很久的Rails错误。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.