My setup is a little different but I'll try to explain. I work for a company that manages a senior-living kiosk, where "vendors" and "guests" sign in and out when they visit a senior-living community. Our Rails 4 application makes heavy use of RailsAdmin and currently mixes data from an external CRM, SugarCRM, with the regular Postgres records in the primary db. SugarCRM records have their own UUIDs instead of numeric IDs, like f05ecba5-df89-a16a-7cae-56b4fcc3ba471. So one example is that a Vendor has many Visits.
The way this relationship is set up is:
Let's say there is a visits table. This has two columns, visitor_id and sugar_id, both are SugarCRM UUIDs. The Vendors table and Visits table each have a sugar_id string column that represents their UUID in Sugar. The visitor_id column in the Visits table represents the Vendor's SugarCRM UUID at the time of their visit.
I am trying to set up a field in the Vendor edit form that shows related visits.
From the Vendor model, the relationship is setup as has_many :visits, :foreign_key => :visitor_id, :primary_key => :sugar_id
From the Visit side, it's belongs_to :vendor, :foreign_key => :visitor_id, :primary_key => :sugar_id
From the Rails side, everything seems valid. In the Vendor form, the related Visits to a vendor show up in that vendor's multi-select. However, when I double-click to bring up the edit modal, I get what appears to be a 406/format error. Here is what I see in the logs:
Started GET "/admin/visit/4dde8fd3-0774-4dbe-8192-8aa4809b8c67/edit" for ::1 at 2018-08-27 11:43:04 -0400
Processing by RailsAdmin::MainController#edit as JS
Parameters: {"model_name"=>"visit", "id"=>"4dde8fd3-0774-4dbe-8192-8aa4809b8c67"}
User Load (1.1ms) SELECT "users".* FROM "users" WHERE "users"."id" = $1 ORDER BY "users"."id" ASC LIMIT 1 [["id", 1]]
Visit Load (1.7ms) SELECT "human_events".* FROM "human_events" WHERE "human_events"."type" IN ('Visit') AND "human_events"."id" = $1 ORDER BY "human_events"."id" ASC LIMIT 1 [["id", 4]]
Completed 406 Not Acceptable in 164ms
Not notifying due to an invalid api_key
ActionController::UnknownFormat - ActionController::UnknownFormat:
actionpack (4.2.0) lib/action_controller/metal/mime_responds.rb:218:in `respond_to'
rails_admin (1.2.0) lib/rails_admin/config/actions/index.rb:42:in `block (2 levels) in <class:Index>'
rails_admin (1.2.0) app/controllers/rails_admin/main_controller.rb:22:in `instance_eval'
rails_admin (1.2.0) app/controllers/rails_admin/main_controller.rb:22:in `index'
rails_admin (1.2.0) app/controllers/rails_admin/application_controller.rb:69:in `block in <class:ApplicationController>'
activesupport (4.2.0) lib/active_support/rescuable.rb:112:in `instance_exec'
activesupport (4.2.0) lib/active_support/rescuable.rb:112:in `block in handler_for_rescue'
activesupport (4.2.0) lib/active_support/rescuable.rb:80:in `rescue_with_handler'
actionpack (4.2.0) lib/action_controller/metal/rescue.rb:15:in `rescue_with_handler'
actionpack (4.2.0) lib/action_controller/metal/rescue.rb:32:in `rescue in process_action'
actionpack (4.2.0) lib/action_controller/metal/rescue.rb:29:in `process_action'
actionpack (4.2.0) lib/action_controller/metal/instrumentation.rb:31:in `block in process_action'
activesupport (4.2.0) lib/active_support/notifications.rb:164:in `block in instrument'
activesupport (4.2.0) lib/active_support/notifications/instrumenter.rb:20:in `instrument'
activesupport (4.2.0) lib/active_support/notifications.rb:164:in `instrument'
actionpack (4.2.0) lib/action_controller/metal/instrumentation.rb:30:in `process_action'
actionpack (4.2.0) lib/action_controller/metal/params_wrapper.rb:250:in `process_action'
activerecord (4.2.0) lib/active_record/railties/controller_runtime.rb:18:in `process_action'
actionpack (4.2.0) lib/abstract_controller/base.rb:137:in `process'
actionview (4.2.0) lib/action_view/rendering.rb:30:in `process'
actionpack (4.2.0) lib/action_controller/metal.rb:195:in `dispatch'
actionpack (4.2.0) lib/action_controller/metal/rack_delegation.rb:13:in `dispatch'
actionpack (4.2.0) lib/action_controller/metal.rb:236:in `block in action'
actionpack (4.2.0) lib/action_dispatch/routing/route_set.rb:73:in `dispatch'
actionpack (4.2.0) lib/action_dispatch/routing/route_set.rb:42:in `serve'
actionpack (4.2.0) lib/action_dispatch/journey/router.rb:43:in `block in serve'
actionpack (4.2.0) lib/action_dispatch/journey/router.rb:30:in `each'
actionpack (4.2.0) lib/action_dispatch/journey/router.rb:30:in `serve'
actionpack (4.2.0) lib/action_dispatch/routing/route_set.rb:802:in `call'
It appears like due to routing, it's trying to convert that Visit's Sugar ID of 4dde8fd3-0774-4dbe-8192-8aa4809b8c67 into an integer, "4". It's likely that I'm going to be dealing with relationships involving string-based keys for now, there are millions of records that we're pulling over.
How can I indicate to RailsAdmin that the ID I'm passing it should not be converted to an integer? Is there a way to add an additional route? This problematic behavior on double-click is only for records that are related via Sugar IDs instead of Postgres IDs.
A shot of the related Visits select in the Vendor edit form:
My setup is a little different but I'll try to explain. I work for a company that manages a senior-living kiosk, where "vendors" and "guests" sign in and out when they visit a senior-living community. Our Rails 4 application makes heavy use of RailsAdmin and currently mixes data from an external CRM, SugarCRM, with the regular Postgres records in the primary db. SugarCRM records have their own UUIDs instead of numeric IDs, like
f05ecba5-df89-a16a-7cae-56b4fcc3ba471
. So one example is that a Vendor has many Visits.The way this relationship is set up is:
visits
table. This has two columns,visitor_id
andsugar_id
, both are SugarCRM UUIDs. The Vendors table and Visits table each have a sugar_id string column that represents their UUID in Sugar. The visitor_id column in the Visits table represents the Vendor's SugarCRM UUID at the time of their visit.has_many :visits, :foreign_key => :visitor_id, :primary_key => :sugar_id
belongs_to :vendor, :foreign_key => :visitor_id, :primary_key => :sugar_id
From the Rails side, everything seems valid. In the Vendor form, the related Visits to a vendor show up in that vendor's multi-select. However, when I double-click to bring up the edit modal, I get what appears to be a 406/format error. Here is what I see in the logs:
It appears like due to routing, it's trying to convert that Visit's Sugar ID of
4dde8fd3-0774-4dbe-8192-8aa4809b8c67
into an integer, "4". It's likely that I'm going to be dealing with relationships involving string-based keys for now, there are millions of records that we're pulling over.How can I indicate to RailsAdmin that the ID I'm passing it should not be converted to an integer? Is there a way to add an additional route? This problematic behavior on double-click is only for records that are related via Sugar IDs instead of Postgres IDs.
A shot of the related Visits select in the Vendor edit form: