1

I was wondering if there is a way to easily access methods/classes from the lib folder in migrations? I found a way to require them with

require File.expand_path("../../lib/my_library")

I don't really like this and I was wondering if there is a more common way to include those libraries required by the migration?

pinkpanther
  • 4,612
  • 2
  • 36
  • 60

1 Answers1

3

rake db:migrate load all rails environment, so you can just add lib in autoload in application.rb file like this and it should work.

config.autoload_paths += Dir["#{config.root}/lib/**/"]
Ivan Shamatov
  • 1,396
  • 1
  • 9
  • 16
  • Just as I thought. I don't unterstand why they don't add it always. I mean, the lib directory is something special isn't it? But thanks for your answer. :) –  Jun 03 '13 at 10:28