1

I know that in Ruby __FILE__ refers to the current file, but what does it refer to when creating a path such as this and why is it needed as a second argument to expand_path?

set :views, File.expand_path('../../views', __FILE__)

For example, if __FILE__ refers to the current file, but there happens to be more than one file in the views folder, what exactly does __FILE__ refer to?

4

1 回答 1

3

Since you are using a relative path in '../../views', you need a reference point to expand the path. The second argument, which happens to be __FILE__ in this case, overrides the default reference point, which is the current working directory.

Ruby Doc File.expand_path

于 2012-12-22T05:14:31.367 回答