{"action":"created","issue":{"url":"https://api.github.com/repos/toptal/chewy/issues/140","labels_url":"https://api.github.com/repos/toptal/chewy/issues/140/labels{/name}","comments_url":"https://api.github.com/repos/toptal/chewy/issues/140/comments","events_url":"https://api.github.com/repos/toptal/chewy/issues/140/events","html_url":"https://github.com/toptal/chewy/issues/140","id":63317279,"number":140,"title":"Performing Update of Index when Related Models are updated","user":{"login":"jshultz","id":342353,"avatar_url":"https://avatars.githubusercontent.com/u/342353?v=3","gravatar_id":"","url":"https://api.github.com/users/jshultz","html_url":"https://github.com/jshultz","followers_url":"https://api.github.com/users/jshultz/followers","following_url":"https://api.github.com/users/jshultz/following{/other_user}","gists_url":"https://api.github.com/users/jshultz/gists{/gist_id}","starred_url":"https://api.github.com/users/jshultz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jshultz/subscriptions","organizations_url":"https://api.github.com/users/jshultz/orgs","repos_url":"https://api.github.com/users/jshultz/repos","events_url":"https://api.github.com/users/jshultz/events{/privacy}","received_events_url":"https://api.github.com/users/jshultz/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":33,"created_at":"2015-03-20T21:59:57Z","updated_at":"2015-03-22T04:43:45Z","closed_at":null,"body":"I have an Index that includes several related models, for example:\r\n\r\ndefine_type Document.includes(:subject, :objectives, :teacher)\r\n\r\nWhen I update Teacher I would like for the Document to be updated with that new information, such as if they change their name.\r\n\r\nBased on the documentation, I should be able to, in the Teacher model add the following:\r\n\r\nupdate_index('documents#document') { self }\r\n\r\nor, if I'm using ChewyKiqqer:\r\n\r\nasync_update_index index: 'documents#document'\r\n\r\nI've tried it both ways, but I don't see the index update. In the latter case, I see Sidekiq fire off a job, but the index doesn't update. \r\n\r\nWhat am I doing wrong?\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/toptal/chewy/issues/comments/84521263","html_url":"https://github.com/toptal/chewy/issues/140#issuecomment-84521263","issue_url":"https://api.github.com/repos/toptal/chewy/issues/140","id":84521263,"user":{"login":"jshultz","id":342353,"avatar_url":"https://avatars.githubusercontent.com/u/342353?v=3","gravatar_id":"","url":"https://api.github.com/users/jshultz","html_url":"https://github.com/jshultz","followers_url":"https://api.github.com/users/jshultz/followers","following_url":"https://api.github.com/users/jshultz/following{/other_user}","gists_url":"https://api.github.com/users/jshultz/gists{/gist_id}","starred_url":"https://api.github.com/users/jshultz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jshultz/subscriptions","organizations_url":"https://api.github.com/users/jshultz/orgs","repos_url":"https://api.github.com/users/jshultz/repos","events_url":"https://api.github.com/users/jshultz/events{/privacy}","received_events_url":"https://api.github.com/users/jshultz/received_events","type":"User","site_admin":false},"created_at":"2015-03-22T04:43:44Z","updated_at":"2015-03-22T04:43:44Z","body":"Interesting. So, it does seem that I have to wrap the related models in the strategy in order for the update to work. The down side to this is that I can't do asynchronous updates using sidekiq that way which may be a deal breaker for us. \r\n\r\nOddly, enough, in the main materials model which is what is what we're indexing in Elastic Search, I have:\r\n\r\n`\r\n  include ChewyKiqqer::Mixin\r\n\r\n  async_update_index index: 'materials#material'\r\n`\r\nAnd it works fine, no need to wrap anything in a strategy. So why the related models are not working the same way is a mystery.\r\n\r\n\r\n"}}