expand_path
expand_path(p1, p2 = v2)
public
Converts a pathname to an absolute pathname. Relative paths are referenced from the current working directory of the process unless dir_string is given, in which case it will be used as the starting point. The given pathname may start with a “~”, which expands to the process owner’s home directory (the environment variable HOME must be set correctly). “~user” expands to the named user’s home directory.
File.expand_path("~oracle/bin") #=> "/home/oracle/bin" File.expand_path("../../bin", "/tmp/x") #=> "/bin"
Argument Ordering
Be aware that the order of arguments for this method is the opposite of File.join:
File.expand_path('foo', '/bar') # => "/bar/foo" File.join('foo', '/bar') # => "foo/bar"
Require file from the same folder
If you want to require file from the same folder, the simplest way is
require File.expand_path('../file-to-require', __FILE__)
If your file is /lib/book.rb
File.expand_path('../page', '/lib/book.rb') => '/lib/page.rb'
Anothery way
This Worked For Me
require File.expand_path('../app/models/extenstions/active_record_ext', File.dirname(__FILE__))
I did this in application.rb