[RailsAdmin] Could not load model xxxxx, assuming model is non existing warning

1,966 views
Skip to first unread message

Eric Hochberger

unread,
Nov 28, 2012, 1:22:33 PM11/28/12
to rails...@googlegroups.com
So I use the spree (https://github.com/spree/spree) style of monkey patching using model_decorator.rb style files in my app folder.  This is, however, making RailsAdmin freak out in 0.2.x on in my warnings.

The files, like tag_decorator.rb, look like:

Tag.class_eval do

end


Ideas for a solution?

Jori Hardman

unread,
Dec 3, 2012, 4:41:32 PM12/3/12
to rails...@googlegroups.com
I noticed the same thing in my app after upgrading to 0.3.0. It looks like the code responsible for loading models into Rails Admin was modified to include "/**/*.rb" for all of your app's autoload paths. The reasoning behind this is given in a comment:

# app/models/module/class.rb => module/class.rb => module/class => Module::Class

So basically, if you have models that are part of a module (e.g. Vehicle::Car which would live in app/models/vehicle/car.rb), Rails Admin will now include the model by default.

The problem is, my autoload paths include my lib folder, meaning that message is thrown for every file that does not follow rails naming conventions. In my case, I have a folder in lib called "extensions" which houses extensions to some ruby standard libraries (like String). All files are then required via a rails initializer. Rails Admin expects my lib/extensions/string.rb to describe an Extensions::String class per rails naming conventions which is obviously not the case, so the message is printed.

For you, Rails Admin reads the tag_decorator.rb filename and expects there to be a TagDecorator class per rails module/class naming conventions. Upon failing to find that class, it spits that message to console. It's not necessarily an error, just a warning. It would be nice if you could specify Rails Admin's load paths, but right now, there is no options for that. I was thinking about submitting a issue to github, but the only drawback right now is those annoying messages on server boot.

Benoit Bénézech

unread,
Dec 5, 2012, 2:57:47 AM12/5/12
to rails...@googlegroups.com
Hello all,

Before these warnings, loading error were silently dismissed, which lead to some confusion, as in 'Why is my model not in the sidebar?'. Now every model (or assumed as such with Rails autoload_path) is either added or logged.

Maybe the situation can be bettered by refining the rescue LoadError, NameError to print more precise warnings and add an option to dismiss them.

The relevant code is here: 


I don't know if it's a good idea to create RailsAdmin load path configuration. It is RailsAdmin as in Rails' admin, and you really are expected to follow Rails conventions.
RailsAdmin should provide options for configuration over Rails's if the expected behavior cannot be obtained automatically in all situations, which is not the case here.
Reply all
Reply to author
Forward
0 new messages