This project is archived and is in readonly mode.

#3556 ✓resolved
Trevor Turk

app_generator should disallow or fix invalid application name

Reported by Trevor Turk | December 9th, 2009 @ 10:06 PM

After following these instructions to generate a Rails 3 application:

http://oscardelben.com/articles/2009/12/06/how-to-test-rails-3.html

...I noticed a problem with the AppGenerator. I'm having trouble getting my Rails 3 tests to run, so apologies for not being able to provide a patch or failing test case.

If you run "rails test-project" from the Rails 3 pre gem you'll see that the application name ends up being invalid. This is immediately apparent if you look in config.ru, but the name is used elsewhere as well.

I see that app_generator.rb is calling classify on line 185. I'm taking a wild guess that this may be the area of concern...?

'test-project'.classify => "Test-project"

Perhaps an error could be raised if an invalid application name was provided, or the name could be converted in a more robust way. I'm sure there's a better way to accomplish the latter, but one possible solution might be something like:

'test-project'.gsub(/[^[:alpha:]]/, '_').classify => "TestProject"

...or even...

'test....project'.gsub(/[^[:alpha:]]/, '_').squeeze('_').classify

I think this warrants more discussion, but I wanted to kick things off at least.

Thanks!

Comments and changes to this ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>

People watching this ticket

Referenced by

Pages