Does rails have an opposite of ‘humanize’ for strings?

the string.parameterize.underscore will give you the same result

"Employee salary".parameterize.underscore       # => employee_salary
"Some Title: Sub-title".parameterize.underscore # => some_title_sub_title

or you can also use which is slightly more succinct (thanks @danielricecodes).

  • Rails < 5 Employee salary".parameterize("_") # => employee_salary
  • Rails > 5 Employee salary".parameterize(separator: "_") # => employee_salary

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)