sferik/rails_admin — Issue #923: error when searching on a model with no name field
Author: jjb
Created: 2012-01-10 01:10:45+00:00
State: open

I posted this problem [on the email list](https://groups.google.com/forum/#!msg/rails_admin/Wa60U-RRlEE/y9aX_bGRQOUJ), and @bbenezech suggested i make a ticket.

I have a model that does not have a name field. I have it under rails_admin with the default config-- it's listed in "included_models" and does not have any custom configuration.

When I try to do a search on my other models, it works as expected.

When I try to do a search on this one model, I get the bellow error. this is the only model that does not have a "name" column, hence my guess that that is the culprit. I haven't dug very deep into the rails_admin code to chase this.

undefined method `name' for nil:NilClass

{"sort_reverse"=>"false",
"utf8"=>"✓",
"model_name"=>"email_addresses",
"sort"=>"id",
"query"=>"consumer"}

activesupport (3.1.3) lib/active_support/whiny_nil.rb:48:in `method_missing'
/Users/john/.rbenv/versions/ree-1.8.7-2011.03/lib/ruby/gems/1.8/bundler/gems/rails_admin-5579332f8a58/lib/rails_admin/abstract_model.rb:47:in `initialize'
/Users/john/.rbenv/versions/ree-1.8.7-2011.03/lib/ruby/gems/1.8/bundler/gems/rails_admin-5579332f8a58/lib/rails_admin/config/fields/base.rb:91:in `new'
/Users/john/.rbenv/versions/ree-1.8.7-2011.03/lib/ruby/gems/1.8/bundler/gems/rails_admin-5579332f8a58/lib/rails_admin/config/fields/base.rb:91
/Users/john/.rbenv/versions/ree-1.8.7-2011.03/lib/ruby/gems/1.8/bundler/gems/rails_admin-5579332f8a58/lib/rails_admin/config/fields/base.rb:86:in `map'
/Users/john/.rbenv/versions/ree-1.8.7-2011.03/lib/ruby/gems/1.8/bundler/gems/rails_admin-5579332f8a58/lib/rails_admin/config/fields/base.rb:86
/Users/john/.rbenv/versions/ree-1.8.7-2011.03/lib/ruby/gems/1.8/bundler/gems/rails_admin-5579332f8a58/lib/rails_admin/config/base.rb:88:in `instance_eval'
/Users/john/.rbenv/versions/ree-1.8.7-2011.03/lib/ruby/gems/1.8/bundler/gems/rails_admin-5579332f8a58/lib/rails_admin/config/base.rb:88:in `searchable_columns'
/Users/john/.rbenv/versions/ree-1.8.7-2011.03/lib/ruby/gems/1.8/bundler/gems/rails_admin-5579332f8a58/lib/rails_admin/adapters/active_record.rb:151:in `get_conditions_hash'
/Users/john/.rbenv/versions/ree-1.8.7-2011.03/lib/ruby/gems/1.8/bundler/gems/rails_admin-5579332f8a58/lib/rails_admin/adapters/active_record.rb:150:in `each'
/Users/john/.rbenv/versions/ree-1.8.7-2011.03/lib/ruby/gems/1.8/bundler/gems/rails_admin-5579332f8a58/lib/rails_admin/adapters/active_record.rb:150:in `get_conditions_hash'
/Users/john/.rbenv/versions/ree-1.8.7-2011.03/lib/ruby/gems/1.8/bundler/gems/rails_admin-5579332f8a58/app/controllers/rails_admin/main_controller.rb:367:in `get_collection'
/Users/john/.rbenv/versions/ree-1.8.7-2011.03/lib/ruby/gems/1.8/bundler/gems/rails_admin-5579332f8a58/app/controllers/rails_admin/main_controller.rb:287:in `list_entries'
/Users/john/.rbenv/versions/ree-1.8.7-2011.03/lib/ruby/gems/1.8/bundler/gems/rails_admin-5579332f8a58/app/controllers/rails_admin/main_controller.rb:60:in `index'
actionpack (3.1.3) lib/action_controller/metal/implicit_render.rb:4:in `send_action'
actionpack (3.1.3) lib/action_controller/metal/implicit_render.rb:4:in `send_action'
actionpack (3.1.3) lib/abstract_controller/base.rb:167:in `process_action'
actionpack (3.1.3) lib/action_controller/metal/rendering.rb:10:in `process_action'
actionpack (3.1.3) lib/abstract_controller/callbacks.rb:18:in `process_action'
activesupport (3.1.3) lib/active_support/callbacks.rb:497:in `_run__1766623449__process_action__199225275__callbacks'
activesupport (3.1.3) lib/active_support/callbacks.rb:386:in `send'
activesupport (3.1.3) lib/active_support/callbacks.rb:386:in `_run_process_action_callbacks'
activesupport (3.1.3) lib/active_support/callbacks.rb:81:in `send'
activesupport (3.1.3) lib/active_support/callbacks.rb:81:in `run_callbacks'
actionpack (3.1.3) lib/abstract_controller/callbacks.rb:17:in `process_action'
actionpack (3.1.3) lib/action_controller/metal/rescue.rb:17:in `process_action'
actionpack (3.1.3) lib/action_controller/metal/instrumentation.rb:30:in `process_action'
activesupport (3.1.3) lib/active_support/notifications.rb:53:in `instrument'
activesupport (3.1.3) lib/active_support/notifications/instrumenter.rb:21:in `instrument'
activesupport (3.1.3) lib/active_support/notifications.rb:53:in `instrument'
actionpack (3.1.3) lib/action_controller/metal/instrumentation.rb:29:in `process_action'
actionpack (3.1.3) lib/action_controller/metal/params_wrapper.rb:201:in `process_action'
activerecord (3.1.3) lib/active_record/railties/controller_runtime.rb:18:in `process_action'
newrelic_rpm (3.3.1) lib/new_relic/agent/instrumentation/rails3/action_controller.rb:34:in `process_action'
newrelic_rpm (3.3.1) lib/new_relic/agent/instrumentation/controller_instrumentation.rb:255:in `perform_action_with_newrelic_trace'
newrelic_rpm (3.3.1) lib/new_relic/agent/method_tracer.rb:242:in `trace_execution_scoped'
newrelic_rpm (3.3.1) lib/new_relic/agent/instrumentation/controller_instrumentation.rb:250:in `perform_action_with_newrelic_trace'
newrelic_rpm (3.3.1) lib/new_relic/agent/instrumentation/rails3/action_controller.rb:33:in `process_action'
actionpack (3.1.3) lib/abstract_controller/base.rb:121:in `process'
actionpack (3.1.3) lib/abstract_controller/rendering.rb:45:in `process'
actionpack (3.1.3) lib/action_controller/metal.rb:193:in `dispatch'
actionpack (3.1.3) lib/action_controller/metal/rack_delegation.rb:14:in `dispatch'
actionpack (3.1.3) lib/action_controller/metal.rb:236:in `action'
actionpack (3.1.3) lib/action_dispatch/routing/route_set.rb:65:in `call'
actionpack (3.1.3) lib/action_dispatch/routing/route_set.rb:65:in `dispatch'
actionpack (3.1.3) lib/action_dispatch/routing/route_set.rb:29:in `call'
rack-mount (0.8.3) lib/rack/mount/route_set.rb:152:in `call'
rack-mount (0.8.3) lib/rack/mount/code_generation.rb:96:in `recognize'
rack-mount (0.8.3) lib/rack/mount/code_generation.rb:68:in `optimized_each'
rack-mount (0.8.3) lib/rack/mount/code_generation.rb:95:in `recognize'
rack-mount (0.8.3) lib/rack/mount/route_set.rb:141:in `call'
actionpack (3.1.3) lib/action_dispatch/routing/route_set.rb:532:in `call'
railties (3.1.3) lib/rails/engine.rb:456:in `call'
railties (3.1.3) lib/rails/railtie/configurable.rb:30:in `send'
railties (3.1.3) lib/rails/railtie/configurable.rb:30:in `method_missing'
rack-mount (0.8.3) lib/rack/mount/prefix.rb:26:in `call'
rack-mount (0.8.3) lib/rack/mount/route_set.rb:152:in `call'
rack-mount (0.8.3) lib/rack/mount/code_generation.rb:96:in `recognize'
rack-mount (0.8.3) lib/rack/mount/code_generation.rb:82:in `optimized_each'
rack-mount (0.8.3) lib/rack/mount/code_generation.rb:95:in `recognize'
rack-mount (0.8.3) lib/rack/mount/route_set.rb:141:in `call'
actionpack (3.1.3) lib/action_dispatch/routing/route_set.rb:532:in `call'
rack-pjax (0.5.5) lib/rack/pjax.rb:12:in `call'
oa-core (0.2.6) lib/omniauth/strategy.rb:44:in `call!'
oa-core (0.2.6) lib/omniauth/strategy.rb:30:in `call'
oa-core (0.2.6) lib/omniauth/strategy.rb:44:in `call!'
oa-core (0.2.6) lib/omniauth/strategy.rb:30:in `call'
oa-core (0.2.6) lib/omniauth/strategy.rb:44:in `call!'
oa-core (0.2.6) lib/omniauth/strategy.rb:30:in `call'
oa-core (0.2.6) lib/omniauth/strategy.rb:44:in `call!'
oa-core (0.2.6) lib/omniauth/strategy.rb:30:in `call'
oa-core (0.2.6) lib/omniauth/strategy.rb:44:in `call!'
oa-core (0.2.6) lib/omniauth/strategy.rb:30:in `call'
oa-core (0.2.6) lib/omniauth/strategy.rb:44:in `call!'
oa-core (0.2.6) lib/omniauth/strategy.rb:30:in `call'
oa-core (0.2.6) lib/omniauth/strategy.rb:44:in `call!'
oa-core (0.2.6) lib/omniauth/strategy.rb:30:in `call'
oa-core (0.2.6) lib/omniauth/strategy.rb:44:in `call!'
oa-core (0.2.6) lib/omniauth/strategy.rb:30:in `call'
oa-core (0.2.6) lib/omniauth/strategy.rb:44:in `call!'
oa-core (0.2.6) lib/omniauth/strategy.rb:30:in `call'
oa-core (0.2.6) lib/omniauth/strategy.rb:44:in `call!'
oa-core (0.2.6) lib/omniauth/strategy.rb:30:in `call'
oa-core (0.2.6) lib/omniauth/strategy.rb:44:in `call!'
oa-core (0.2.6) lib/omniauth/strategy.rb:30:in `call'
oa-core (0.2.6) lib/omniauth/builder.rb:30:in `call'
newrelic_rpm (3.3.1) lib/new_relic/rack/browser_monitoring.rb:23:in `call'
newrelic_rpm (3.3.1) lib/new_relic/rack/developer_mode.rb:24:in `call'
sass (3.1.12) lib/sass/./sass/plugin/rack.rb:54:in `call'
warden (1.1.0) lib/warden/manager.rb:35:in `call'
warden (1.1.0) lib/warden/manager.rb:34:in `catch'
warden (1.1.0) lib/warden/manager.rb:34:in `call'
actionpack (3.1.3) lib/action_dispatch/middleware/best_standards_support.rb:17:in `call'
rack (1.3.6) lib/rack/etag.rb:23:in `call'
rack (1.3.6) lib/rack/conditionalget.rb:25:in `call'
actionpack (3.1.3) lib/action_dispatch/middleware/head.rb:14:in `call'
remotipart (1.0.1) lib/remotipart/middleware.rb:30:in `call'
actionpack (3.1.3) lib/action_dispatch/middleware/params_parser.rb:21:in `call'
actionpack (3.1.3) lib/action_dispatch/middleware/flash.rb:247:in `call'
rack (1.3.6) lib/rack/session/abstract/id.rb:195:in `context'
rack (1.3.6) lib/rack/session/abstract/id.rb:190:in `call'
actionpack (3.1.3) lib/action_dispatch/middleware/cookies.rb:331:in `call'
activerecord (3.1.3) lib/active_record/query_cache.rb:64:in `call'
activerecord (3.1.3) lib/active_record/connection_adapters/abstract/connection_pool.rb:477:in `call'
actionpack (3.1.3) lib/action_dispatch/middleware/callbacks.rb:29:in `call'
activesupport (3.1.3) lib/active_support/callbacks.rb:392:in `_run_call_callbacks'
activesupport (3.1.3) lib/active_support/callbacks.rb:81:in `send'
activesupport (3.1.3) lib/active_support/callbacks.rb:81:in `run_callbacks'
actionpack (3.1.3) lib/action_dispatch/middleware/callbacks.rb:28:in `call'
actionpack (3.1.3) lib/action_dispatch/middleware/reloader.rb:68:in `call'
rack (1.3.6) lib/rack/sendfile.rb:101:in `call'
actionpack (3.1.3) lib/action_dispatch/middleware/remote_ip.rb:48:in `call'
actionpack (3.1.3) lib/action_dispatch/middleware/show_exceptions.rb:47:in `call'
railties (3.1.3) lib/rails/rack/logger.rb:13:in `call'
rack (1.3.6) lib/rack/methodoverride.rb:24:in `call'
rack (1.3.6) lib/rack/runtime.rb:17:in `call'
activesupport (3.1.3) lib/active_support/cache/strategy/local_cache.rb:72:in `call'
rack (1.3.6) lib/rack/lock.rb:15:in `call'
actionpack (3.1.3) lib/action_dispatch/middleware/static.rb:53:in `call'
rack-ssl (1.3.2) lib/rack/ssl.rb:27:in `call'
railties (3.1.3) lib/rails/engine.rb:456:in `call'
railties (3.1.3) lib/rails/railtie/configurable.rb:30:in `send'
railties (3.1.3) lib/rails/railtie/configurable.rb:30:in `method_missing'
rack (1.3.6) lib/rack/lint.rb:48:in `_call'
rack (1.3.6) lib/rack/lint.rb:36:in `call'
rack (1.3.6) lib/rack/showexceptions.rb:24:in `call'
rack (1.3.6) lib/rack/commonlogger.rb:20:in `call'
rack (1.3.6) lib/rack/chunked.rb:41:in `call'
rack (1.3.6) lib/rack/content_length.rb:14:in `call'
unicorn (4.1.1) lib/unicorn/http_server.rb:528:in `process_client'
unicorn (4.1.1) lib/unicorn/http_server.rb:600:in `worker_loop'
newrelic_rpm (3.3.1) lib/new_relic/agent/instrumentation/unicorn_instrumentation.rb:17:in `call'
newrelic_rpm (3.3.1) lib/new_relic/agent/instrumentation/unicorn_instrumentation.rb:17:in `worker_loop'
unicorn (4.1.1) lib/unicorn/http_server.rb:485:in `spawn_missing_workers'
unicorn (4.1.1) lib/unicorn/http_server.rb:135:in `start'
unicorn (4.1.1) bin/unicorn:121
/Users/john/.rbenv/versions/ree-1.8.7-2011.03/lib/ruby/gems/1.8/bin/unicorn:19:in `load'
/Users/john/.rbenv/versions/ree-1.8.7-2011.03/lib/ruby/gems/1.8/bin/unicorn:19