camelize

Hi,

I'm getting the following error with a plugin I'm using on rails 2.1 :

  Plugins::Restful-authentication::Lib" is not a valid constant name!

The plugin gets installed in a directory named /vendor/plugins/restful-authentication.

I traced this error down to the camelize function. The doc mentions this:

   +camelize+ will also convert '/' to '::' which is useful for converting paths to namespaces.

Does this suggest that the output of camelize are accepted constant names?

Should this never raise a NameError? :

   ActiveSupport::Inflector.constantize(any_string.camelize)

for example:

    ActiveSupport::Inflector.constantize("ace/foo-bar/a".camelize)

Is the opinion that only directories and file names matching /\w*/ are accepted? And they can't start with a digit? Or should we support the above case where a directory contains a minus sign?

Lawrence

Hi Lawrence,

I experienced the same issue, of course camelize doesn't work properly, but just add the following two lines to the plugin init.rb I can run Rails:

require File.dirname(__FILE__) + '/lib/authorization'
require File.dirname(__FILE__) + '/lib/authorization/stateful_roles'

I didn't investigate why this hack works, because of lack of time.

Luca

I renamed the dir the plugin is sitting in from /authorization-plugin to /authorization.

Lawrence