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
Post a Comment