Advertisement
Guest User

Untitled

a guest
Aug 4th, 2015
217
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.52 KB | None | 0 0
  1. class Gardener < ActiveRecord::Base
  2. belongs_to :group
  3. has_many :answers
  4. #has_and_belongs_to_many :questionnaires, join_table: 'gardener_questionnaires'
  5. #has_and_belongs_to_many :questionnaires, join_table: 'gardener_questionnaires'
  6. #has_many :answers, through: :gardener_questionnaires
  7. has_many :attendance_registers_training_sessions
  8. has_many :attendance_registers, through: :attendance_registers_training_sessions
  9. has_many :support_visits, dependent: :destroy
  10. has_one :garden, dependent: :destroy
  11. has_one :living_arrangement, dependent: :destroy
  12. has_one :sfl, dependent: :destroy
  13. has_one :education, dependent: :destroy
  14. has_one :employment, dependent: :destroy
  15. has_one :grant, dependent: :destroy
  16. has_one :ability, dependent: :destroy
  17. has_one :experience, dependent: :destroy
  18. has_one :health, dependent: :destroy
  19. has_one :general_statement, dependent: :destroy
  20. has_one :expenditure, dependent: :destroy
  21. has_many :follow_up_visits
  22. #has_many :documents
  23. # has_attached_file :avatar, :styles => {:thumb => "100x100>"}
  24. # validates_attachment_content_type :avatar, :content_type => ["image/jpg", "image/jpeg", "image/png", "image/gif"]
  25. has_attached_file :avatar, dependent: :destroy,
  26. :storage => :dropbox,
  27. :dropbox_credentials => "#{Rails.root}/config/dropbox.yml",
  28. :styles => { :medium => "300x300>", :thumb => "100x100>" },
  29. :default_url => "/images/missing_pic.jpeg",
  30. :dropbox_options => {
  31. :path => proc { |style| "#{style}/#{id}_#{avatar.original_filename}"},
  32. :unique_filename => true
  33. }
  34. validates_attachment_content_type :avatar, :content_type => ["image/jpg", "image/jpeg", "image/png", "image/gif"]
  35. validates :first_name, length: {minimum: 2, too_short: "First name needs at least 2 characters"}
  36. validates :last_name , length: {minimum: 2, too_short: "Last name needs at least 2 characters"}
  37. validates :contact_number, length: {minimum: 9, too_short: "Contact numbers need to have 10 characters", maximum: 11, too_long: "Contact numbers need to have 10 characters" }
  38. validates :address , length: {minimum: 4, too_short: "Address needs at least 4 characters"}
  39. validates :id_number, :length => { :is => 13,
  40. :too_short => "must have at least %{count} words",
  41. :too_long => "must have at most %{count} words"},
  42. :uniqueness => true
  43. validates :race, :presence => true
  44.  
  45. has_attached_file :resume, dependent: :destroy,
  46. :storage => :dropbox,
  47. :dropbox_credentials => "#{Rails.root}/config/dropbox.yml"
  48. end
  49.  
  50. #mount_uploader :image, ImageUploader
  51.  
  52. def active?
  53. status == 'active'
  54. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement