Iván Cortés
Iván Cortés

Reputation: 652

How can I get the Rails template path from inside it?

When a Rails template is used: rails new todo -m ~/template.rb, how can I get the real template path from inside it?

Dir.pwd does not work because when the template is used, its commands are run under the new app scope, so the result is the new application path not the template's path itself.

Upvotes: 0

Views: 242

Answers (1)

builder-7000
builder-7000

Reputation: 7627

To get the directory of the currently running file:

File.dirname(__FILE__)

Upvotes: 1

Related Questions