{"action":"closed","issue":{"url":"https://api.github.com/repos/Sology/maily_herald/issues/24","repository_url":"https://api.github.com/repos/Sology/maily_herald","labels_url":"https://api.github.com/repos/Sology/maily_herald/issues/24/labels{/name}","comments_url":"https://api.github.com/repos/Sology/maily_herald/issues/24/comments","events_url":"https://api.github.com/repos/Sology/maily_herald/issues/24/events","html_url":"https://github.com/Sology/maily_herald/issues/24","id":192353813,"number":24,"title":"Accessing devise/cancancan helpers in initializer doesn't work","user":{"login":"gnycl","id":290838,"avatar_url":"https://avatars.githubusercontent.com/u/290838?v=3","gravatar_id":"","url":"https://api.github.com/users/gnycl","html_url":"https://github.com/gnycl","followers_url":"https://api.github.com/users/gnycl/followers","following_url":"https://api.github.com/users/gnycl/following{/other_user}","gists_url":"https://api.github.com/users/gnycl/gists{/gist_id}","starred_url":"https://api.github.com/users/gnycl/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gnycl/subscriptions","organizations_url":"https://api.github.com/users/gnycl/orgs","repos_url":"https://api.github.com/users/gnycl/repos","events_url":"https://api.github.com/users/gnycl/events{/privacy}","received_events_url":"https://api.github.com/users/gnycl/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2016-11-29T17:56:23Z","updated_at":"2016-12-10T21:01:09Z","closed_at":"2016-12-10T21:01:09Z","body":"In the `config/initializer/maily_herald.rb` file I'd like to limit scope of available users based on who is signed in. This is a multi-tenant application that has different sets of users based on account.\r\n\r\nIn the example documentation, the scope context given is always `User.all`. I'm trying replace this logic using Devise or CanCanCan's `current_user` or `current_ability` helpers; eg.:\r\n\r\n```\r\n  config.context :all_users do |context|\r\n    context.scope { User.where(:account => current_user.account) }\r\n    context.destination {|user| user.email}\r\n    context.attributes do |user|\r\n      attribute_group(:user) do\r\n        attribute(:email) {user.email}\r\n        attribute(:created_at) {user.created_at}\r\n      end\r\n    end\r\n  end\r\n```\r\n\r\nbut cannot access Devise (and Devise helpers like `current_user`) in MailyHerald's initializer file. Any guidance is appreciated."}}
{"actor":{"display_login":"gnycl"}}