camelize

3 views
Skip to first unread message

Lawrence Pit

unread,
Jun 4, 2008, 9:23:17 PM6/4/08
to rubyonra...@googlegroups.com
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

Luca Guidi

unread,
Jun 5, 2008, 2:56:39 AM6/5/08
to rubyonra...@googlegroups.com
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
--
blog: www.lucaguidi.com
Pro-Netics: www.pro-netics.com
Sourcesense - making sense of Open Source: www.sourcesense.com

Lawrence Pit

unread,
Jun 5, 2008, 3:04:31 AM6/5/08
to rubyonra...@googlegroups.com

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

Lawrence

Reply all
Reply to author
Forward
0 new messages