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

I was looking for an answer to this question. unfortunately the answer above (@root) doesn't seem to work in Rails 3.

Here's the variables you can access in Rails 3 app templates (even easier):

@app_name
@app_path

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.


In Rails 3, use the app_name attribute.

See the documentation for the Rails::Generators::AppGenerator.