{"action":"created","issue":{"url":"https://api.github.com/repos/activescaffold/active_scaffold/issues/522","repository_url":"https://api.github.com/repos/activescaffold/active_scaffold","labels_url":"https://api.github.com/repos/activescaffold/active_scaffold/issues/522/labels{/name}","comments_url":"https://api.github.com/repos/activescaffold/active_scaffold/issues/522/comments","events_url":"https://api.github.com/repos/activescaffold/active_scaffold/issues/522/events","html_url":"https://github.com/activescaffold/active_scaffold/issues/522","id":183198418,"number":522,"title":"UnknownPrimaryKey-Exception in has_may :through","user":{"login":"Ladeburger","id":10371899,"avatar_url":"https://avatars.githubusercontent.com/u/10371899?v=3","gravatar_id":"","url":"https://api.github.com/users/Ladeburger","html_url":"https://github.com/Ladeburger","followers_url":"https://api.github.com/users/Ladeburger/followers","following_url":"https://api.github.com/users/Ladeburger/following{/other_user}","gists_url":"https://api.github.com/users/Ladeburger/gists{/gist_id}","starred_url":"https://api.github.com/users/Ladeburger/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Ladeburger/subscriptions","organizations_url":"https://api.github.com/users/Ladeburger/orgs","repos_url":"https://api.github.com/users/Ladeburger/repos","events_url":"https://api.github.com/users/Ladeburger/events{/privacy}","received_events_url":"https://api.github.com/users/Ladeburger/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2016-10-15T09:00:33Z","updated_at":"2016-10-15T09:15:28Z","closed_at":null,"body":"Rails 5.0.0.1\r\nRuby 2.3.1\r\nAS 3.4.41.1\r\n\r\nI try to use AS for an Legacy-Datamodel which has m:n - Relations with additional Informations. So\r\ni want to use has_many : through - Relations Problem is, the Relations have no primary Key. So far,\r\neverything is working fine, except when i want to access an Object from the m:n relation.\r\n\r\nExample:\r\nSystem\r\n  has_many :patchassingnments\r\n  has_many :patches, :through => :patchassignments\r\n\r\nPatch\r\n  has_many :patchassingnments\r\n  has_many :systems, :through => :patchassignments\r\n\r\nPatchassignment\r\n  belongs_to :system\r\n  belongs_to :patch\r\n\r\nListing of Systems: Work\r\nSublisting of Patchassignments: Work\r\nHitting an Patch in the Sublisting: Error\r\n```\r\n\r\nCompleted 500 Internal Server Error in 2ms (ActiveRecord: 0.0ms)\r\n\r\n\r\n  \r\nActiveRecord::UnknownPrimaryKey (Unknown primary key for table patchassignments in model Patchassignment.):\r\n  \r\nactiverecord (5.0.0.1) lib/active_record/relation/finder_methods.rb:445:in `find_with_ids'\r\nactiverecord (5.0.0.1) lib/active_record/relation/finder_methods.rb:66:in `find'\r\nactiverecord (5.0.0.1) lib/active_record/querying.rb:3:in `find'\r\nactiverecord (5.0.0.1) lib/active_record/core.rb:151:in `find'\r\n/home/jan/.bundle/ruby/2.2.0/active_scaffold-fdd479d7f3e4/lib/active_scaffold/finder.rb:371:in `find_if_allowed'\r\n/home/jan/.bundle/ruby/2.2.0/active_scaffold-fdd479d7f3e4/lib/active_scaffold/actions/nested.rb:108:in `nested_parent_record'\r\n/home/jan/.bundle/ruby/2.2.0/active_scaffold-fdd479d7f3e4/lib/active_scaffold/helpers/id_helpers.rb:14:in `nested_parent_id'\r\n/home/jan/.bundle/ruby/2.2.0/active_scaffold-fdd479d7f3e4/lib/active_scaffold/actions/core.rb:243:in `active_scaffold_session_storage_key'\r\n/home/jan/.bundle/ruby/2.2.0/active_scaffold-fdd479d7f3e4/lib/active_scaffold/actions/core.rb:248:in `active_scaffold_session_storage'\r\n/home/jan/.bundle/ruby/2.2.0/active_scaffold-fdd479d7f3e4/lib/active_scaffold/constraints.rb:11:in `active_scaffold_constraints'\r\n/home/jan/.bundle/ruby/2.2.0/active_scaffold-fdd479d7f3e4/lib/active_scaffold/constraints.rb:20:in `register_constraints_with_action_columns'\r\n/home/jan/.bundle/ruby/2.2.0/active_scaffold-fdd479d7f3e4/lib/active_scaffold/actions/nested.rb:31:in `set_nested'\r\n/home/jan/.bundle/ruby/2.2.0/active_scaffold-fdd479d7f3e4/lib/active_scaffold/actions/nested.rb:19:in `nested'\r\n/home/jan/.bundle/ruby/2.2.0/active_scaffold-fdd479d7f3e4/lib/active_scaffold/actions/nested.rb:24:in `nested?'\r\n/home/jan/.bundle/ruby/2.2.0/active_scaffold-fdd479d7f3e4/lib/active_scaffold/actions/core.rb:243:in `active_scaffold_session_storage_key'\r\n/home/jan/.bundle/ruby/2.2.0/active_scaffold-fdd479d7f3e4/lib/active_scaffold/actions/core.rb:248:in `active_scaffold_session_storage'\r\n/home/jan/.bundle/ruby/2.2.0/active_scaffold-fdd479d7f3e4/lib/active_scaffold/actions/core.rb:260:in `handle_user_settings'\r\nactivesupport (5.0.0.1) lib/active_support/callbacks.rb:382:in `block in make_lambda'\r\nactivesupport (5.0.0.1) lib/active_support/callbacks.rb:169:in `call'\r\nactivesupport (5.0.0.1) lib/active_support/callbacks.rb:169:in `block (2 levels) in halting'\r\nactionpack (5.0.0.1) lib/abstract_controller/callbacks.rb:12:in `call'\r\n```\r\n"},"comment":{"url":"https://api.github.com/repos/activescaffold/active_scaffold/issues/comments/253972598","html_url":"https://github.com/activescaffold/active_scaffold/issues/522#issuecomment-253972598","issue_url":"https://api.github.com/repos/activescaffold/active_scaffold/issues/522","id":253972598,"user":{"login":"Ladeburger","id":10371899,"avatar_url":"https://avatars.githubusercontent.com/u/10371899?v=3","gravatar_id":"","url":"https://api.github.com/users/Ladeburger","html_url":"https://github.com/Ladeburger","followers_url":"https://api.github.com/users/Ladeburger/followers","following_url":"https://api.github.com/users/Ladeburger/following{/other_user}","gists_url":"https://api.github.com/users/Ladeburger/gists{/gist_id}","starred_url":"https://api.github.com/users/Ladeburger/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Ladeburger/subscriptions","organizations_url":"https://api.github.com/users/Ladeburger/orgs","repos_url":"https://api.github.com/users/Ladeburger/repos","events_url":"https://api.github.com/users/Ladeburger/events{/privacy}","received_events_url":"https://api.github.com/users/Ladeburger/received_events","type":"User","site_admin":false},"created_at":"2016-10-15T09:15:28Z","updated_at":"2016-10-15T09:15:28Z","body":"For the Model, everythin working fine:\r\n```\r\nirb(main):004:0> s = System.find(15).patchassignments.first.patch\r\n  System Load (0.6ms)  SELECT  \"systems\".* FROM \"systems\" WHERE \"systems\".\"id\" = $1 LIMIT $2  [[\"id\", 15], [\"LIMIT\", 1]]\r\n  Patchassignment Load (0.4ms)  SELECT  \"patchassignments\".* FROM \"patchassignments\" WHERE \"patchassignments\".\"system_id\" = $1 LIMIT $2  [[\"system_id\", 15], [\"LIMIT\", 1]]\r\n  Patch Load (0.4ms)  SELECT  \"patches\".* FROM \"patches\" WHERE \"patches\".\"id\" = $1 LIMIT $2  [[\"id\", 13], [\"LIMIT\", 1]]\r\n=> #<Patch id: 13, name: \"Patch_2\", description: \"This is Patch 2, which is very important\">\r\nirb(main):005:0>\r\n```\r\nI already read about composite-primary-keys but try to avoid them if it is not really neccessary"}}
{"actor":{"display_login":"Ladeburger"}}