{"action":"closed","issue":{"url":"https://api.github.com/repos/vigetlabs/sprig/issues/46","repository_url":"https://api.github.com/repos/vigetlabs/sprig","labels_url":"https://api.github.com/repos/vigetlabs/sprig/issues/46/labels{/name}","comments_url":"https://api.github.com/repos/vigetlabs/sprig/issues/46/comments","events_url":"https://api.github.com/repos/vigetlabs/sprig/issues/46/events","html_url":"https://github.com/vigetlabs/sprig/issues/46","id":46083361,"number":46,"title":"STI issues","user":{"login":"alexanderadam","id":372620,"avatar_url":"https://avatars.githubusercontent.com/u/372620?v=3","gravatar_id":"","url":"https://api.github.com/users/alexanderadam","html_url":"https://github.com/alexanderadam","followers_url":"https://api.github.com/users/alexanderadam/followers","following_url":"https://api.github.com/users/alexanderadam/following{/other_user}","gists_url":"https://api.github.com/users/alexanderadam/gists{/gist_id}","starred_url":"https://api.github.com/users/alexanderadam/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alexanderadam/subscriptions","organizations_url":"https://api.github.com/users/alexanderadam/orgs","repos_url":"https://api.github.com/users/alexanderadam/repos","events_url":"https://api.github.com/users/alexanderadam/events{/privacy}","received_events_url":"https://api.github.com/users/alexanderadam/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2014-10-17T10:04:22Z","updated_at":"2016-06-21T15:09:08Z","closed_at":"2016-06-21T15:09:08Z","body":"Hm my [PR](https://github.com/vigetlabs/sprig/pull/43) wasn't enough anyway and I don't have the time to investigate in it (or write useful tests for it). Sorry. :cry: \r\n\r\nPerhaps this is just an documentation issue how to handle STI models anyway.\r\n\r\nWe just ran into this issue again and I **believe** the problem should be reproducible by a setup like this:\r\n\r\n```ruby\r\nclass Car < ActiveRecord::Base\r\nend\r\n\r\n# type: 'RedCar' but it lives in the `cars` table\r\nclass RedCar < Car\r\nend\r\n```\r\n\r\nWhen we tried to reference models like this, we somehow ran into problems and I believe that's because of the use of the `tableize` method (I would perhaps prefer the `table_name` method if the class responds to it).\r\n\r\nIf you have a `cars.yml` and reference it via `sprig_record(Car, 1)` sprig won't find the record while it just saves the record via\r\n\r\n```ruby\r\nrecords[klass.name.tableize]\r\n```\r\n\r\nSo if you seek via `sprig_record(Car, 1)` it will try to access `records['cars']` instead of `records['red_cars']`.\r\n\r\nIf you try to reference this object via `sprig_record(RedCar, 1)` spring will complain that it never seeded something like that while it just knows about `Car`.\r\n\r\nI'm sorry for my answering latency. :wink:"}}
{"actor":{"display_login":"Fosome"}}