Skip to content

Conversation

@drewbug
Copy link

@drewbug drewbug commented Feb 10, 2016

No description provided.


def actual_root_path
root_path || Dir.pwd
root_path || File.dirname(File.realpath(__FILE__))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would this work? File.new(File.dirname(__FILE__)).realpath

I'm assuming we want to use File.dirname(__FILE__) over __dir__ for ruby version compatibility. too bad.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, in rails > 2.0, this is __dir__

Anyone have an opinion if this change is still necessary?

@kbrock
Copy link
Collaborator

kbrock commented Apr 21, 2016

Fix actual_root_path implementation

Hello @drewbug could you share what you are trying to do here?

@drewbug
Copy link
Author

drewbug commented Apr 21, 2016

@kbrock: The README says: By default, this class will look for a yml file named "countries.yml" in the same directory as the file.

I was just attempting to bring the actual implementation into line with this. I was bitten by this when starting a daemon from a different working directory. My easy workaround is: set_root_path __dir__, but this doesn't work on Ruby versions older than 2.0

@kbrock
Copy link
Collaborator

kbrock commented Apr 21, 2016

Thanks, that is helpful.

Using dir or filename will be the same result. The directory of this gem file, not the caller's dir. Maybe caller or caller_location may be of use?

I'll try and play with this...

@drewbug
Copy link
Author

drewbug commented Apr 25, 2016

You're right, @kbrock, I didn't even think about that. D'oh!

@kbrock
Copy link
Collaborator

kbrock commented Apr 25, 2016

@drewbug there may be a way to look at self.class.method(?).source_location or something?
I'm sure the answer is simple, just have to find it

@syguer syguer added the bug label Apr 4, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants