Remove trailing commas in ruby string

Neha

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

Rajdeep Singh

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.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Check if a String has two or more commas and remove additional commas

From Dev

PHP preg_split remove commas and trailing white-space

From Dev

Remove leading and trailing zeros from a string

From Dev

Remove trailing slash and create query string with .htaccess

From Dev

Remove trailing numbers from string js regexp

From Dev

Remove trailing substring from String in Java

From Dev

remove both commas and white space ruby

From Dev

Cleanest way to remove trailing blanks a string in swift?

From Dev

Remove trailing spaces from each line in a string in ruby

From Dev

How to remove commas at the end of any string

From Dev

Remove unwanted commas from string using php

From Dev

Remove trailing '/' from rails string

From Dev

Remove excess commas from string PHP

From Dev

How to remove a trailing comma from a string (Java)

From Dev

Check if a String has two or more commas and remove additional commas

From Dev

Remove trailing punctuation from concatenated string

From Dev

Remove leading and trailing zeros from a string

From Dev

Remove trailing slash and create query string with .htaccess

From Dev

remove trailing commas using sql

From Dev

Remove beginning or trailing comma from delimited string

From Dev

Delete trailing commas in line

From Dev

Remove trailing string

From Dev

Cleanest way to remove trailing blanks a string in swift?

From Dev

java convert string to int and remove trailing zeros

From Dev

How to remove extra commas in my string?

From Dev

Remove trailing commas from invalid json (to make it valid)

From Dev

Remove trailing slashes from Query String Apache

From Dev

Remove All Characters Trailing an Angle Bracket in Ruby

From Dev

Removing leading and trailing commas

Related Related

  1. 1

    Check if a String has two or more commas and remove additional commas

  2. 2

    PHP preg_split remove commas and trailing white-space

  3. 3

    Remove leading and trailing zeros from a string

  4. 4

    Remove trailing slash and create query string with .htaccess

  5. 5

    Remove trailing numbers from string js regexp

  6. 6

    Remove trailing substring from String in Java

  7. 7

    remove both commas and white space ruby

  8. 8

    Cleanest way to remove trailing blanks a string in swift?

  9. 9

    Remove trailing spaces from each line in a string in ruby

  10. 10

    How to remove commas at the end of any string

  11. 11

    Remove unwanted commas from string using php

  12. 12

    Remove trailing '/' from rails string

  13. 13

    Remove excess commas from string PHP

  14. 14

    How to remove a trailing comma from a string (Java)

  15. 15

    Check if a String has two or more commas and remove additional commas

  16. 16

    Remove trailing punctuation from concatenated string

  17. 17

    Remove leading and trailing zeros from a string

  18. 18

    Remove trailing slash and create query string with .htaccess

  19. 19

    remove trailing commas using sql

  20. 20

    Remove beginning or trailing comma from delimited string

  21. 21

    Delete trailing commas in line

  22. 22

    Remove trailing string

  23. 23

    Cleanest way to remove trailing blanks a string in swift?

  24. 24

    java convert string to int and remove trailing zeros

  25. 25

    How to remove extra commas in my string?

  26. 26

    Remove trailing commas from invalid json (to make it valid)

  27. 27

    Remove trailing slashes from Query String Apache

  28. 28

    Remove All Characters Trailing an Angle Bracket in Ruby

  29. 29

    Removing leading and trailing commas

HotTag

Archive