How can I use a method that is defined in ActiveSupport
module?
For example I wanted to use camelize
method.
I tried this code, but it didn't work with undefined method
error.
require 'active_support'
"foo_bar".camelize
You can require just the part that supplies camelize, rather than all of Active Support:
require 'active_support/core_ext/string'
"camel_this".camelize => "CamelThis"
You'll need to do require 'active_support/all'
This explains it...
http://guides.rubyonrails.org/active_support_core_extensions.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With