Saturday, 15 March 2014

Get path to a ruby project's root directory -



Get path to a ruby project's root directory -

my ruby project looks this:

my_dir - app + controllers + views + models * foo.rb - doc + dummy.txt

inside foo.rb, have constant, used below

path_to_dummy="../../doc/dummy.txt" def bar(path=path_to_dummy) # end

is "../../doc/dummy.txt" right way define path <my_dir>/doc/dummy.txt? doesn't alright, because that's right path app/models

is there way absoutely path project directory, can like:

path_to_dummy=file.jon(project_root, "doc/dummy.txt")

file.join(rails.root, "doc", "dummy.txt")

or

rails.root.join("doc", "dummy.txt")

ruby-on-rails path

No comments:

Post a Comment