【发布时间】:2010-12-10 07:09:33
【问题描述】:
如何使 aasm 事件返回布尔值以外的值?我正在使用aasm 2.2.0
例如有一个 MusicPlayer 模型,它在启动时随机播放一首歌曲
aasm_state :started, :after_enter => :play_song
aasm_state :stopped
aasm_event :start do
:transitions :from => :stopped, :to => :started
end
def play_song
# select and play a song randomly and return the song object
end
现在如果我想在启动播放器时返回当前正在播放的歌曲,我该如何通过'play_song'方法呢?
【问题讨论】:
标签: ruby-on-rails aasm