class AcceptedOffer < ActiveRecord::Base include Workflow belongs_to :customer belongs_to :offer has_many :documents, dependent: :destroy mount_uploader :devis, DevisUploader validates :customer, :presence => true validates :offer, :presence => true workflow_column :state workflow do state :waiting_documents do event :complete_documents, :transitions_to => :devis_available end state :documents_completed end def human_state case state when 'waiting_documents' "En attente des documents à retourner" when 'documents_completed' "Documents retournés et vérifiés" end end def human_admin_state case state when 'waiting_documents' "En attente des documents à retourner" when 'documents_completed' "Documents retournés et vérifiés" end end end