Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

app_generator should disallow or fix invalid application name

#3556

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!

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

State: resolved
Milestone: none
Assigned to: José Valim José Valim
Importance: Low

Activity

  1. Trevor Turk
    Trevor Turk
    • Title changed from app_generator should disallow or fix invalid app_const to app_generator should disallow or fix invalid application name

    December 9th, 2009 @ 10:11 PM

  2. José Valim
    José Valim
    • Assigned user set to José Valim

    January 3rd, 2010 @ 12:30 AM

  3. Repository
  4. José Valim
    José Valim
    • State changed from new to resolved

    Thanks Trevor, fixed!

    January 3rd, 2010 @ 04:18 PM