upmin / upmin-admin-ruby

Framework for creating powerful admin backends with minimal effort in Ruby on Rails.
MIT License
757 stars 66 forks source link

Ignore ActiveRecord tables without associated model. #139

Open svenihoney opened 9 years ago

svenihoney commented 9 years ago

If I activate the ActiveRecord session store as shown on https://github.com/rails/activerecord-session_store, upmin bails out with an "uninitialized constant Upmin::ActiveRecord::SessionStore" with the following exception:

(eval):3:in `model_class'
/tmp/upmin-admin-ruby/lib/upmin/model.rb:165:in `model_class_name'
/tmp/upmin-admin-ruby/lib/upmin/model.rb:189:in `search_path'
/tmp/upmin-admin-ruby/app/views/layouts/upmin/_navbar.html.haml:14:in `block in __tmp_upmin_admin_ruby_app_views_layouts_upmin__navbar_html_haml___3179528665945118893_70041221274420'
/tmp/upmin-admin-ruby/app/views/layouts/upmin/_navbar.html.haml:12:in `each'
/tmp/upmin-admin-ruby/app/views/layouts/upmin/_navbar.html.haml:12:in `__tmp_upmin_admin_ruby_app_views_layouts_upmin__navbar_html_haml___3179528665945118893_70041221274420'
vendor/bundle/ruby/2.1.0/gems/actionview-4.2.0.rc2/lib/action_view/template.rb:145:in `block in render'
vendor/bundle/ruby/2.1.0/gems/activesupport-4.2.0.rc2/lib/active_support/notifications.rb:166:in `instrument'

This can be reproduced in my application as well as with a freshly checked out test app active_record42 from github. I use ruby 2.1.5 with rbenv.

Is there any place where additional configuration has to be done? As soon as I remove the session store gem from the Gemfile, upmin is back working.

Regards, Sven

mbrookes commented 9 years ago

Hi Sven,

Yes, ActiveRecord tables without an associated model will break things, so you have to whitelist your models with config.models

This has come up a couple of times now in different forms (there's PR #126 for HABTM tables for example), so I'm thinking we might need to be smarter about what gets counted as a model by default.