{"action":"created","issue":{"url":"https://api.github.com/repos/aasm/aasm/issues/388","repository_url":"https://api.github.com/repos/aasm/aasm","labels_url":"https://api.github.com/repos/aasm/aasm/issues/388/labels{/name}","comments_url":"https://api.github.com/repos/aasm/aasm/issues/388/comments","events_url":"https://api.github.com/repos/aasm/aasm/issues/388/events","html_url":"https://github.com/aasm/aasm/issues/388","id":167899363,"number":388,"title":"Permissible states not respecting guard parameters","user":{"login":"froske","id":13108747,"avatar_url":"https://avatars.githubusercontent.com/u/13108747?v=3","gravatar_id":"","url":"https://api.github.com/users/froske","html_url":"https://github.com/froske","followers_url":"https://api.github.com/users/froske/followers","following_url":"https://api.github.com/users/froske/following{/other_user}","gists_url":"https://api.github.com/users/froske/gists{/gist_id}","starred_url":"https://api.github.com/users/froske/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/froske/subscriptions","organizations_url":"https://api.github.com/users/froske/orgs","repos_url":"https://api.github.com/users/froske/repos","events_url":"https://api.github.com/users/froske/events{/privacy}","received_events_url":"https://api.github.com/users/froske/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2016-07-27T16:33:52Z","updated_at":"2016-09-21T11:18:54Z","closed_at":"2016-08-22T07:58:43Z","body":"I understand calling for permissible states works with guards (ref issue #54), but I can't get it to work when my guard has a parameter.  It seems like it's not getting passed to the guard (only when I call for permissible states.\r\n\r\nExample:\r\n\r\n```\r\nstate :new, :reviewed, :finalized\r\n\r\nevent :mark_as_reviewed do\r\n  transitions :from => :new, :to => :reviewed, :guards => [:user_is_manager?]\r\nend\r\n\r\n...\r\n\r\ndef user_is_manager?(usr)\r\n  ok = false\r\n  if usr.has_role? :manager\r\n    ok = true\r\n  end\r\n  return ok\r\nend\r\n```\r\n\r\n```\r\n$ u = User.find(100)\r\n$ u.has_role? :manager\r\n=> true\r\n\r\n$item.aasm.current_state\r\n=> :new\r\n\r\n$ item.may_mark_as_reviewed?(u)\r\n=> true\r\n\r\n$ item.aasm.states(:permitted => true, :usr => u).map(&:name)\r\n=> NoMethodError: undefined method `has_role?' for nil:NilClass.....\r\n\r\n```\r\n\r\nbut the guard works in other instances with a parameter, like when I actually try to change the state.\r\n\r\n```\r\n$ item.mark_as_reviewed!(u)\r\n=> true\r\n\r\n$ item.aasm.current_state\r\n=> :reviewed\r\n```\r\n\r\nIf I do a `puts usr.inspect` inside the guard method, it shows me that the User object did in fact make it when I called `item.may_mark_reviewed?(u)`  but when I call for permitted states it's just nil.\r\n\r\nI've tried every syntax I can think of. \r\n\r\nWhat am I missing?"},"comment":{"url":"https://api.github.com/repos/aasm/aasm/issues/comments/248582223","html_url":"https://github.com/aasm/aasm/issues/388#issuecomment-248582223","issue_url":"https://api.github.com/repos/aasm/aasm/issues/388","id":248582223,"user":{"login":"anilmaurya","id":1912864,"avatar_url":"https://avatars.githubusercontent.com/u/1912864?v=3","gravatar_id":"","url":"https://api.github.com/users/anilmaurya","html_url":"https://github.com/anilmaurya","followers_url":"https://api.github.com/users/anilmaurya/followers","following_url":"https://api.github.com/users/anilmaurya/following{/other_user}","gists_url":"https://api.github.com/users/anilmaurya/gists{/gist_id}","starred_url":"https://api.github.com/users/anilmaurya/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/anilmaurya/subscriptions","organizations_url":"https://api.github.com/users/anilmaurya/orgs","repos_url":"https://api.github.com/users/anilmaurya/repos","events_url":"https://api.github.com/users/anilmaurya/events{/privacy}","received_events_url":"https://api.github.com/users/anilmaurya/received_events","type":"User","site_admin":false},"created_at":"2016-09-21T11:18:54Z","updated_at":"2016-09-21T11:18:54Z","body":"@froske Thank you for reporting this bug, its fixed now in version `4.11.1 `."}}
{"actor":{"display_login":"anilmaurya"}}