I'm making a Rails template file as introduced below:
I have a big file I want to make, so instead of doing:
file "bigfile.txt", <<-EOF
content of the file...
EOF
I want to read the content from another file. What I have now is:
file "public/stylesheets/sass/960.sass", File.read(File.expand_path(File.join(File.dirname(__FILE__), "960.sass")))
The file is located in the same directory as the rails template file. The problem is: when I try to make a rails app with the template (i.e., rails new_app -m rails_template/rails_template.rb
, I get the following error:
The template [rails_template/rails_template.rb] could not be loaded. Error: (eval):129:in `read': No such file or directory - /Users/myusername/Desktop/new_app/960.sass
This is all because __SELF__
is not working the way I expected. I expect __SELF__
to be the template file itself, but in reality, __SELF__
is poiting to the root of the app or somewhere else.
Is there a way to load file in a rails template?