{"action":"created","issue":{"url":"https://api.github.com/repos/aasm/aasm/issues/331","repository_url":"https://api.github.com/repos/aasm/aasm","labels_url":"https://api.github.com/repos/aasm/aasm/issues/331/labels{/name}","comments_url":"https://api.github.com/repos/aasm/aasm/issues/331/comments","events_url":"https://api.github.com/repos/aasm/aasm/issues/331/events","html_url":"https://github.com/aasm/aasm/issues/331","id":135855993,"number":331,"title":"Is it possible to use a different aasm 'column' for ruby classes?","user":{"login":"bahbbc","id":763533,"avatar_url":"https://avatars.githubusercontent.com/u/763533?v=3","gravatar_id":"","url":"https://api.github.com/users/bahbbc","html_url":"https://github.com/bahbbc","followers_url":"https://api.github.com/users/bahbbc/followers","following_url":"https://api.github.com/users/bahbbc/following{/other_user}","gists_url":"https://api.github.com/users/bahbbc/gists{/gist_id}","starred_url":"https://api.github.com/users/bahbbc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bahbbc/subscriptions","organizations_url":"https://api.github.com/users/bahbbc/orgs","repos_url":"https://api.github.com/users/bahbbc/repos","events_url":"https://api.github.com/users/bahbbc/events{/privacy}","received_events_url":"https://api.github.com/users/bahbbc/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/aasm/aasm/labels/callbacks","name":"callbacks","color":"bfdadc"},{"url":"https://api.github.com/repos/aasm/aasm/labels/waiting%20for%20response","name":"waiting for response","color":"fbca04"}],"state":"open","locked":false,"assignee":{"login":"alto","id":3209,"avatar_url":"https://avatars.githubusercontent.com/u/3209?v=3","gravatar_id":"","url":"https://api.github.com/users/alto","html_url":"https://github.com/alto","followers_url":"https://api.github.com/users/alto/followers","following_url":"https://api.github.com/users/alto/following{/other_user}","gists_url":"https://api.github.com/users/alto/gists{/gist_id}","starred_url":"https://api.github.com/users/alto/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alto/subscriptions","organizations_url":"https://api.github.com/users/alto/orgs","repos_url":"https://api.github.com/users/alto/repos","events_url":"https://api.github.com/users/alto/events{/privacy}","received_events_url":"https://api.github.com/users/alto/received_events","type":"User","site_admin":false},"milestone":null,"comments":3,"created_at":"2016-02-23T20:33:13Z","updated_at":"2016-02-24T13:00:53Z","closed_at":null,"body":"If I correctly understood the docs, if you are using ActiveRecord you can create a migration and change the default column from aasm. \r\n\r\n```ruby\r\ninclude AASM\r\n\r\n  aasm :column => :another_name do\r\n    state :process, initial: true\r\n    state :approve\r\n    state :refuse\r\n  end\r\n```\r\n\r\nBut is it possible to use an attribute from a ruby class as well? using the `column` I wasn't able to do so. As a workaround I used some  `before_all_events` and `after_all_events` to set the current state machine in the attribute that I wanted, but this doesn't work for the initial state, no matter which callbacks I use. Is there a solution for it?\r\n\r\n```ruby\r\naasm do\r\n  state :preparation, initial: true\r\n  state :sent_to_analysis\r\n  state :end_integration\r\n\r\n  before_all_events :get_status\r\n  after_all_events :set_status\r\n\r\n  event :send_to_analysis do\r\n    transitions from: :preparation, to: :sent_to_analysis\r\n  end\r\n\r\n  event :end_integration do\r\n    transitions from: :sent_to_analysis, to: :end_integration\r\n  end\r\nend\r\n\r\nprivate\r\ndef get_status\r\n  self.aasm.current_state = self.status\r\nend\r\n\r\ndef set_status\r\n  self.status = self.aasm.current_state\r\nend\r\n```"},"comment":{"url":"https://api.github.com/repos/aasm/aasm/issues/comments/188247225","html_url":"https://github.com/aasm/aasm/issues/331#issuecomment-188247225","issue_url":"https://api.github.com/repos/aasm/aasm/issues/331","id":188247225,"user":{"login":"bahbbc","id":763533,"avatar_url":"https://avatars.githubusercontent.com/u/763533?v=3","gravatar_id":"","url":"https://api.github.com/users/bahbbc","html_url":"https://github.com/bahbbc","followers_url":"https://api.github.com/users/bahbbc/followers","following_url":"https://api.github.com/users/bahbbc/following{/other_user}","gists_url":"https://api.github.com/users/bahbbc/gists{/gist_id}","starred_url":"https://api.github.com/users/bahbbc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bahbbc/subscriptions","organizations_url":"https://api.github.com/users/bahbbc/orgs","repos_url":"https://api.github.com/users/bahbbc/repos","events_url":"https://api.github.com/users/bahbbc/events{/privacy}","received_events_url":"https://api.github.com/users/bahbbc/received_events","type":"User","site_admin":false},"created_at":"2016-02-24T13:00:53Z","updated_at":"2016-02-24T13:00:53Z","body":"I already understand what is happening! I my specs I only initialize the object and expected to have the status already settled. \r\n\r\n```ruby\r\nit 'starts with status preparation' do\r\n  subject = described_class.new\r\n\r\n  expect(subject.status).to eql(:preparation)\r\nend\r\n```\r\n\r\nBut it only works if I call the aasm state... For example, if I do `aasm.current_state` in the spec it works. I though that the initial state and it's callbacks would be initialized with the object, but it looks like they do only if I verify the it's state."}}