Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use Ruby on Rails functions within plain (non ROR) Ruby file

Ruby on Rails contains some very useful functions like blank? and date time functions that are not present in vanilla ruby.

What is the gem to enables these and how do I use it?

like image 981
joseph Avatar asked Jan 26 '23 04:01

joseph


1 Answers

The gem you are referring to is ActiveSupport and the features can be loaded all at once from core_ext.rb (which loads each file in the core_ext Directory) e.g.

require 'active_support/core_ext'

or loaded individually based the features and classes you are interested in e.g.

require 'active_support/core_ext/object/blank'
like image 143
engineersmnky Avatar answered Jan 29 '23 06:01

engineersmnky