I am getting the following value in my params: "45,284"
How can I remove the the leading and trailing double quotes from my string?
The output that I should get is: 45,284
You can do this to your params[:userValues]
to make it suitable for IN
clause in your query
"45,284".split(",").map(&:to_i) #=> [45, 248]
So for params[:userValues]
it will be
user_values = params[:userValues].split(",").map(&:to_i)
Now the query will look like this
@user = User.where('is_active = ? and is_support_user = ? and id IN (?)', true, false, user_values).order(:user_name)
This will work, try it out
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments