我正在使用Rails 3.2.2,使用aasm gem,我有这样的Document模型:
class Document < ActiveRecord::Base
include AASM
aasm do
state :unread, :initial => true
state :read
state :closed
event :view do
transitions :to => :read, :from => [:unread]
end
event :close do
transitions :to => :closed, :from => [:read, :unread]
end
end
Run Code Online (Sandbox Code Playgroud)
现在在我的控制台上:
? ? bundle exec rails c
Loading development environment (Rails 3.2.2)
irb(main):006:0> Document.create!(:title => 'test')
(0.2ms) BEGIN
SQL (0.3ms) INSERT INTO `documents` (`aasm_state`, `checklist_id`, `created_at`, `description`, `dir`, `planned_date`, `procedure_id`, `section`, `subsection`, `title`, `updated_at`) …Run Code Online (Sandbox Code Playgroud) 我想检查Ruby on Rails上的页面加载是否启用了javascript和cookie。因此,如果有人尝试打开它,网站应该显示一条消息,表明他无法继续进行操作。