I am using rails 3.2.12
ruby 1.9.3
and mongoid 3.1.7
as orm/driver for mongo 2.6
I have an address class which can be used in multiple models
class Address < ApplicationRecord
embedded_in :addressable, polymorphic: true
end
class Customer < ApplicationRecord
embeds_one :address, autobuild: true, as: :addressable
end
class Invoice < ApplicationRecord
embeds_one :address, autobuild: true, as: :addressable
end
Not every time but on random I am getting an error on my view
Started GET "/customers/asdadsdsdsdsds?sid=abcdfsd" for ------ at 2018-03-16 10:38:11 -0400
Processing by CustomersController#show as HTML
Parameters: {"sid"=>"xyz", "id"=>"abc"}
Rendered customers/show.html.haml within layouts/application (2.5ms)
Completed 500 Internal Server Error in 439ms
Rendered /usr/local/rvm/gems/ruby-1.9.3-p547/gems/exception_notification-3.0.1/lib/exception_notifier/views/exception_notifier/_request.text.erb (0.4ms)
Rendered /usr/local/rvm/gems/ruby-1.9.3-p547/gems/exception_notification-3.0.1/lib/exception_notifier/views/exception_notifier/_title.text.erb (0.1ms)
Rendered /usr/local/rvm/gems/ruby-1.9.3-p547/gems/exception_notification-3.0.1/lib/exception_notifier/views/exception_notifier/_session.text.erb (0.6ms)
Rendered /usr/local/rvm/gems/ruby-1.9.3-p547/gems/exception_notification-3.0.1/lib/exception_notifier/views/exception_notifier/_title.text.erb (0.1ms)
Rendered /usr/local/rvm/gems/ruby-1.9.3-p547/gems/exception_notification-3.0.1/lib/exception_notifier/views/exception_notifier/_environment.text.erb (9.0ms)
Rendered /usr/local/rvm/gems/ruby-1.9.3-p547/gems/exception_notification-3.0.1/lib/exception_notifier/views/exception_notifier/_title.text.erb (0.1ms)
Rendered /usr/local/rvm/gems/ruby-1.9.3-p547/gems/exception_notification-3.0.1/lib/exception_notifier/views/exception_notifier/_backtrace.text.erb (0.2ms)
Rendered /usr/local/rvm/gems/ruby-1.9.3-p547/gems/exception_notification-3.0.1/lib/exception_notifier/views/exception_notifier/_title.text.erb (0.1ms)
Rendered /usr/local/rvm/gems/ruby-1.9.3-p547/gems/exception_notification-3.0.1/lib/exception_notifier/views/exception_notifier/exception_notification.text.erb (22.0ms)
Sent mail to me (60ms)
ActionView::Template::Error (undefined method `instantiate' for Address:Class):
40:
41: .dl-horizontal
42: %dt Address
43: %dd= customer.address
44:
45: .dl-horizontal
app/views/customers/show.html.haml:43:in `_app_views_customers_show_html_haml__4324924039767281630_61736740'
more from backtrace
-------------------------------
Backtrace:
-------------------------------
mongoid (3.1.7) lib/mongoid/factory.rb:40:in `from_db'
mongoid (3.1.7) lib/mongoid/relations/builders/embedded/one.rb:21:in `build'
mongoid (3.1.7) lib/mongoid/relations/accessors.rb:43:in `create_relation'
mongoid (3.1.7) lib/mongoid/relations/accessors.rb:26:in `__build__'
mongoid (3.1.7) lib/mongoid/relations/accessors.rb:116:in `block (2 levels) in get_relation'
mongoid (3.1.7) lib/mongoid/threaded/lifecycle.rb:125:in `_loading'
mongoid (3.1.7) lib/mongoid/relations/accessors.rb:115:in `block in get_relation'
mongoid (3.1.7) lib/mongoid/threaded/lifecycle.rb:84:in `_building'
mongoid (3.1.7) lib/mongoid/relations/accessors.rb:114:in `get_relation'
mongoid (3.1.7) lib/mongoid/relations/accessors.rb:223:in `block in getter'
app/views/customers/show.html.haml:43:in `_app_views_customers_show_html_haml___1573920893515992280_74752380'
actionpack (3.2.12) lib/action_view/template.rb:145:in `block in render'
Aucun commentaire:
Enregistrer un commentaire