Skip to content

Instantly share code, notes, and snippets.

View martinstreicher's full-sized avatar
🎯
Focusing

Martin Streicher martinstreicher

🎯
Focusing
View GitHub Profile
require 'spec_helper'
def assign(*entities, &block)
entities = [entities].flatten.compact.uniq
entities.each { |e| yield(e) }
end
describe 'Visibility Rules' do
disconnect_sunspot
require 'spec_helper'
def assign(*entities, &block)
entities = [entities].flatten.compact.uniq
entities.each { |e| yield(e) }
end
describe 'Visibility Rules' do
disconnect_sunspot
Prescription.generate
ActiveRecord::UnknownAttributeError: unknown attribute: doctor
from /Users/strike/projects/ohp/onehealthpass_core/vendor/rails/activerecord/lib/active_record/base.rb:2906:in `assign_attributes'
from /Users/strike/projects/ohp/onehealthpass_core/vendor/rails/activerecord/lib/active_record/base.rb:2902:in `each'
from /Users/strike/projects/ohp/onehealthpass_core/vendor/rails/activerecord/lib/active_record/base.rb:2902:in `assign_attributes'
from /Users/strike/projects/ohp/onehealthpass_core/vendor/rails/activerecord/lib/active_record/base.rb:2775:in `attributes='
from /Users/strike/projects/ohp/onehealthpass_core/vendor/rails/activerecord/lib/active_record/base.rb:2473:in `initialize'
from /Users/strike/projects/ohp/onehealthpass_core/vendor/plugins/object_daddy/lib/object_daddy.rb:36:in `new'
from /Users/strike/projects/ohp/onehealthpass_core/vendor/plugins/object_daddy/lib/object_daddy.rb:36:in `spawn'
from /Users/strike/projects/ohp/onehealthpass_core/vendor/plugins/object_daddy
class Prescription < ActiveRecord::Base
belongs_to :doctor, :class_name => 'User', :foreign_key => 'doctor_id'
belongs_to :patient, :class_name => 'User', :foreign_key => 'patient_id'
belongs_to :pharmacist, :class_name => 'User', :foreign_key => 'pharmacist_id'
belongs_to :prescribable, :polymorphic => true
has_many :prescription_transactions
validates_presence_of :patient
validates_presence_of :uuid
# ...
state_machine :state, :initial => :new do
before_transition any => :published do |project|
project.errors.add_to_base('bid cannot be empty') if project.bid.nil?
project.errors.add_to_base('domain must be verified') unless project.verified?
false unless project.errors.empty?
end
before_transition any => :paid do |project|
project.errors.add_to_base('domain must be verified') unless project.verified?
false unless project.errors.empty?
# Examples:
#
# Reprocess all versions of User#avatar
# rake carrierwave:reprocess class=User mounted_uploader=avatar
#
# Reprocess the versions: thumb, small, medium for User#avatar
# rake carrierwave:reprocess class=User mounted_uploader=avatar versions='thumb, small, medium'
namespace :carrierwave do
#!/usr/bin/ruby
module Helpers
LINE = 80
def announcing(msg)
print msg
yield
print "." * (LINE - msg.size - 6)
puts "\e[32m[DONE]\e[0m"
end