开发者

No such file to load, Model/Lib naming conflict?

I'm working on a Rails application. I have a Module called Animals. Inside this Module is a Class with the same name as one of my Models (Dog).

show_animal action:


def show_animal
  require 'Animals/Bear.rb' #Works
  require 'Animals/Dog.rb' #Fails
end

So the first require defin开发者_C百科itely works, the seconds fails. MissingSourceFile (no such file to load -- Animals/Dog.rb):

I noticed that Dog.rb is the same file name as one of my models, is that what's causing this? I'm using Webrick.


Try using the full path:

require File.join(RAILS_ROOT, 'lib', 'Animals', 'Dog.rb')
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜