ruby on rails - How to turn a require __FILE__ + 'file.rb' into require 'file'? -


this question has answer here:

i have @ top of file:

parser_spec.rb:

require file.dirname(__file__) + '/parser.rb' 

which has class inside:

parser.rb:

class scraper   def scrape_department(file) 

both files in rails/project folder.

how can include file doing require 'parser'?

file.dirname(__file__) 

just means file in directory of caller.

try using

require_relative 'parser' 

by way, suggest renaming file scraper.rb since name of class inside file.


Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -