Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Symbol with underscores causes error in cache_helper.rb #348

Open
secondstreetmedia opened this issue Aug 20, 2015 · 1 comment
Open

Symbol with underscores causes error in cache_helper.rb #348

secondstreetmedia opened this issue Aug 20, 2015 · 1 comment

Comments

@secondstreetmedia
Copy link

When passing a symbol with underscores (e.g. :my_things) to the _cache_keys_for_all_ method in app/helpers/cache_helper.rb, such as in the following line:

localized_cache cache_keys_for_all(:my_things) do

it throws the following error:

LoadError - Unable to autoload constant My_thing

due to the code in line 9 of the file, which appears in the _cache_key_for_all_ method, called by the _cache_keys_for_all_ method:

9: klass = klass_name.to_s.singularize.capitalize.constantize

Using the example of :my_things, this line will try to set klass to "My_thing", triggering the error when it attempts to constantize.

I believe it should be:

9: klass = klass_name.to_s.singularize.camelize.constantize

which would set klass to "MyThing", which seems to be the correct form.

@jurre
Copy link
Contributor

jurre commented Aug 21, 2015

Nice catch, your proposed change makes sense, I'd love to see a PR with it!

EOengineer added a commit to EOengineer/Hours that referenced this issue Feb 1, 2017
jurre added a commit that referenced this issue Feb 2, 2017
…error

#348: resolves errors when passing a symbol with underscores.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants