Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I require libraries in your Rails directory from the console?

I have a script called query.rb in my lib directory. I want to require it so I can run it from the Rails console. I wonder if this is possible. The script work fine from within the application, so I know it's well formed and functional.

like image 389
picardo Avatar asked Oct 25 '25 21:10

picardo


1 Answers

For Rails 3+, use load "#{Rails.root}/lib/your_lib_file.rb" load works like require, but allows you to re-load files as you edit them (unlike require, which you cant run again). See https://stackoverflow.com/a/6361502/513739

like image 56
Excalibur Avatar answered Oct 28 '25 13:10

Excalibur