NameError in Refinery/admin/dashboard#index uninitialized constant

184 views
Skip to first unread message

David W

unread,
Dec 4, 2013, 4:49:48 PM12/4/13
to refine...@googlegroups.com
I'm using a Refinery extension someone else made. Can't describe the actual extension in detail, sorry. When I log in as any user that has access to the extension, except the admin, I see this error:

uninitialized constant Refinery::SomeExtensionModule::SomeExtensionClass

Extracted source (around line #4):

1: <div id='recent_activity'> 2: <h2><%= t('.latest_activity') %></h2> 3: <% if (activity = @recent_activity.collect { |a| 4: activity_message_for(a) 5: }.reject(&:blank?)).present? %> 6: <ul class='clickable'> 7: <% activity.each do |message| %>

I think the dashboard is trying to load information about recent activity related to this extension, and gettting an error.

I don't have time to research this further right now because I have a workaround, but constantly seeing 500 errors every time I log in and ignoring them is a bad habit. Any ideas?

Thanks!
David

David W

unread,
Dec 13, 2013, 7:14:57 PM12/13/13
to refine...@googlegroups.com
Just noticed there are actually 2 NameErrors.

I also did take a look and I can't find a SomeExtensionClassONE class definition or SomeExtensionClassTWO class definition defined anywhere in the extension.

I think there is a syntax error somewhere, but I don't see anything wrong in the extension. The app and extension were both developed around the same time. Maybe the app has some outdated stuff in it that was later changed in the extension. The extension is in /vendor/extensions/.

The ActionView::Template::Error below was only logged for SomeExtensionClassONE. I'm not sure why that part was not repeated in the log for SomeExtensionClassTWO.

Started GET "/refinery" for 127.0.0.1 at 2013-12-13 15:37:16 -0800
Processing by Refinery::Admin::DashboardController#index as HTML
 Parameters: {"locale"=>:us}
NameError raised while getting recent activity for dashboard.
uninitialized constant Refinery::SomeExtensionModule::SomeExtensionClassONE
 > /Users/david/.rvm/gems/ruby-1.9.3-p448@tenjin/gems/activesupport-3.2.15/lib/active_support/inflector/methods.rb:230:in `block in constantize'
………
NameError raised while getting recent activity for dashboard.
uninitialized constant Refinery::SomeExtensionModule::SomeExtensionClassTWO
 > /Users/david/.rvm/gems/ruby-1.9.3-p448@tenjin/gems/activesupport-3.2.15/lib/active_support/inflector/methods.rb:230:in `block in constantize'
………
 Rendered vendor/cache/refinerycms-136682465788/dashboard/app/views/refinery/admin/dashboard/_recent_activity.html.erb (5.8ms)
 Rendered vendor/cache/refinerycms-136682465788/dashboard/app/views/refinery/admin/dashboard/_records.html.erb (42.5ms)
 Rendered vendor/cache/refinerycms-136682465788/dashboard/app/views/refinery/admin/dashboard/index.html.erb within layouts/refinery/admin (45.7ms)
Completed 500 Internal Server Error in 120.2ms

ActionView::Template::Error (uninitialized constant Refinery::SomeExtensionModule::SomeExtensionClassONE):

   1: <div id='recent_activity'>
   2:   <h2><%= t('.latest_activity') %></h2>
   3:   <% if (activity = @recent_activity.collect { |a|
   4:           activity_message_for(a)
   5:         }.reject(&:blank?)).present? %>
   6:     <ul class='clickable'>
   7:     <% activity.each do |message| %>
 activesupport (3.2.15) lib/active_support/inflector/methods.rb:230:in `block in constantize'
 activesupport (3.2.15) lib/active_support/inflector/methods.rb:229:in `each'
 activesupport (3.2.15) lib/active_support/inflector/methods.rb:229:in `constantize'
 activesupport (3.2.15) lib/active_support/core_ext/string/inflections.rb:54:in `constantize'
…….

Philip Arndt

unread,
Dec 13, 2013, 9:24:30 PM12/13/13
to refine...@googlegroups.com
The fake class names are confusing, can you use actual names from your application?

Look in vendor/extensions/the_extension/lib/refinery/the_extension/engine.rb and you may see mention of these classes.

David W

unread,
Dec 14, 2013, 12:01:00 PM12/14/13
to refine...@googlegroups.com
Here's a gist of engine.rb:

https://gist.github.com/Vinietskyzilla/7961780

Again, both the original admin RefineryCMS user and other RefineryCMS users can access this extension in /refinery, but the 500 error only occurs for the non-admin users. The admin has access to the extension but doesn't get a 500 error on the dashboard page.

I replaced the fake class names with more interesting fake names. (Sorry for all the secrecy, I'm never sure what's okay to share. Rule of thumb seems to be, share as little as possible.)

Refinery::SomeExtensionModule::SomeExtensionClassONE is now Refinery::Bunny::Shoes

Refinery::SomeExtensionModule::SomeExtensionClassTWO is now Refinery::Bunny::Hat

Philip Arndt

unread,
Dec 14, 2013, 2:16:04 PM12/14/13
to refine...@googlegroups.com
The problem with fake values is that we can't be sure why it's failing, because we have no idea whether the real values do something strange.

For example you'd never have a namespace Refinery::Bunny it'd more likely be Refinery::Bunnies - unless you purposefully overrode the defaults, which would give us clues.

David W

unread,
Dec 14, 2013, 3:53:54 PM12/14/13
to refine...@googlegroups.com
Sorry, I know it's a pain. Thanks for your patience. I'm paranoid about security issues so I try to be secretive on the public Internet. The extension is closed source, unfortunately. Anyway.

Well, I tried to match capitalization and singular/plural for the names but I guess it's still not quite right. It's more like

Refinery::Bunny::ShoeHorns
and
Refinery::Bunny::Hat

I updated the gist to match: https://gist.github.com/Vinietskyzilla/7961780

David W

unread,
Dec 16, 2013, 4:37:28 PM12/16/13
to refine...@googlegroups.com
I just noticed in the log that this happens with the admin user as well (NameErrors) but for some reason a 500 error response is not sent. I guess if you are logged in as the admin, errors like these get caught.
Reply all
Reply to author
Forward
0 new messages