hashrocket / decent_exposure

A helper for creating declarative interfaces in controllers
MIT License
1.81k stars 107 forks source link

Fix 'wrong constant name' error (Rails 4.1.0beta1) #106

Closed jtomaszewski closed 10 years ago

jtomaszewski commented 10 years ago

I keep having 'NameError: wrong constant name' wherever I use any kind of expose in my controllers in Rails 4.1 (was working great in 4.0).

So I digged a little and the reason is that:

path # => "CarsController"
path[0...(path.rindex('::') || 0)] # => "" (empty string)
"".constantize # (rails 4.0) => Object 
"".constantize # (rails 4.1) => NameError: wrong constant name

Here is a small change that fixes that. P.S. maintainers of mongoid gem had similar problem.

emaiax commented 10 years ago

When is this gonna be merged? Thanks!

jgdavey commented 10 years ago

Merged: f9f4db1cf09edf32b5187c2710b56f41f14023e3