Search code examples
ruby-on-railsrubytemplates

Accessing the app name from inside a rails template when generating rails app


I'm messing around with rails 2.3 templates and want to be able to use the app name as a variable inside my template, so when I use...
rails appname -m path/to/template.rb
...I want to be able to access appname inside template.rb. Anyone know how to do this?
Thanks


Solution

  • Thanks for the answers. Mike Woodhouse, you were so close. Turns out, all you need to do to access the appname from inside your rails template is...

    @root.split('/').last  
    

    The @root variable is the first thing created when initializing templates and is available inside your rails templates. RAILS_ROOT does not work.