{"action":"created","issue":{"url":"https://api.github.com/repos/toptal/chewy/issues/359","repository_url":"https://api.github.com/repos/toptal/chewy","labels_url":"https://api.github.com/repos/toptal/chewy/issues/359/labels{/name}","comments_url":"https://api.github.com/repos/toptal/chewy/issues/359/comments","events_url":"https://api.github.com/repos/toptal/chewy/issues/359/events","html_url":"https://github.com/toptal/chewy/issues/359","id":144629833,"number":359,"title":"define_type with time-dependent ActiveRecord scope","user":{"login":"kenzan100","id":570263,"avatar_url":"https://avatars.githubusercontent.com/u/570263?v=3","gravatar_id":"","url":"https://api.github.com/users/kenzan100","html_url":"https://github.com/kenzan100","followers_url":"https://api.github.com/users/kenzan100/followers","following_url":"https://api.github.com/users/kenzan100/following{/other_user}","gists_url":"https://api.github.com/users/kenzan100/gists{/gist_id}","starred_url":"https://api.github.com/users/kenzan100/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kenzan100/subscriptions","organizations_url":"https://api.github.com/users/kenzan100/orgs","repos_url":"https://api.github.com/users/kenzan100/repos","events_url":"https://api.github.com/users/kenzan100/events{/privacy}","received_events_url":"https://api.github.com/users/kenzan100/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2016-03-30T15:32:52Z","updated_at":"2016-03-30T15:48:45Z","closed_at":null,"body":"I'm writing this to make sure if this is an intended effect :smiley: \r\n\r\nsuppose you have a AR model with scope like\r\n`scope :published, -> { where(\"articles.published_at <= ?\", DateTime.now) }`\r\n\r\nand with Chewy mapper\r\n```\r\nclass ArticlesIndex < Chewy::Index\r\n  define_type Article.published do\r\n    # all the mappings\r\n  end\r\nend\r\n```\r\n\r\nand this won't give you a fresh `published` scope when invoking `update_index` in the AR model.\r\n\r\nI solved it with using `delete_if` proc, but if you'd like me to submit a PR reminding this behaviour on README, I'm more than happy to do so :hand: \r\n\r\nThanks so much for proving such a handy gem to Ruby btw :smiley_cat: "},"comment":{"url":"https://api.github.com/repos/toptal/chewy/issues/comments/203497773","html_url":"https://github.com/toptal/chewy/issues/359#issuecomment-203497773","issue_url":"https://api.github.com/repos/toptal/chewy/issues/359","id":203497773,"user":{"login":"kenzan100","id":570263,"avatar_url":"https://avatars.githubusercontent.com/u/570263?v=3","gravatar_id":"","url":"https://api.github.com/users/kenzan100","html_url":"https://github.com/kenzan100","followers_url":"https://api.github.com/users/kenzan100/followers","following_url":"https://api.github.com/users/kenzan100/following{/other_user}","gists_url":"https://api.github.com/users/kenzan100/gists{/gist_id}","starred_url":"https://api.github.com/users/kenzan100/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kenzan100/subscriptions","organizations_url":"https://api.github.com/users/kenzan100/orgs","repos_url":"https://api.github.com/users/kenzan100/repos","events_url":"https://api.github.com/users/kenzan100/events{/privacy}","received_events_url":"https://api.github.com/users/kenzan100/received_events","type":"User","site_admin":false},"created_at":"2016-03-30T15:48:45Z","updated_at":"2016-03-30T15:48:45Z","body":"I'm still new to Elasticsearch (newbies will look for high-level wrapper like this), so thank you for the suggestions!\r\n\r\nI'll consider them (and probably stick to Elasticsearch friendly way)."}}