Skip to content

Instantly share code, notes, and snippets.

@graybill
Created August 12, 2010 20:31
Show Gist options
  • Save graybill/521670 to your computer and use it in GitHub Desktop.
Save graybill/521670 to your computer and use it in GitHub Desktop.
include Newflow
define_workflow do
state :draft, :start => true do
transitions_to :published, :if => lambda { true }
end
state :published do
transitions_to :unpublished , :if => lambda { true }
end
state :unpublished, :stop => true
end
/////
>> l = Link.new
=> #<Link id: nil, title: nil, description: nil, url: nil, created_at: nil, updated_at: nil, photo_file_name: nil, photo_content_type: nil, photo_file_size: nil, photo_updated_at: nil, popular: nil, featured: nil, workflow_state: "draft">
>> l.transition!
=> :unpublished
>> l.current_state = 'draft'
=> "draft"
>> l.transition!
=> :unpublished
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment