I have a script called query.rb in my lib directory. I want to require it to run it from the Rails console. I wonder if this is possible. The script works fine from the application, so I know that it is well-formed and functional.
require "#{RAILS_ROOT}/lib/query"
For Rails 3+, use load "#{Rails.root}/lib/your_lib_file.rb" load works like require, but allows you to reload files as you edit them (unlike require, which you cannot run again). See fooobar.com/questions/98809 / ...
load "#{Rails.root}/lib/your_lib_file.rb"
>> $:.unshift 'lib' >> require 'query'
Rails 4 +:
require "#{Rails.root}/lib/query"
Source: https://habr.com/ru/post/1783732/More articles:What is equivalent to for-each loop in jQuery? - javascriptStruggling with regex to match only two characters, not three - javascriptHow to uniquely identify a client machine in an ASP.NET application? - web-applicationsStop and play AudioQueue fast - objective-cVisual Studio 2010 ClickOnce prerequisites from the same place - visual-studio-2010Digitally Sign Email - .netjQuery Slider - How to have different times for each image? - jqueryIs there an easy way to tell you what tasks the Java executor is currently performing? - javaWmAutoUpdate - Has anyone used it? Do Not Rollback - c #How to print a PDF file created using iText? - javaAll Articles