wethu
2/19/2014 - 12:22 AM

Models_Tables.rb

class Detail < ActiveRecord::Base
	belongs_to :product
  belongs_to :job_detail
  
	has_many :properties, :dependent => :destroy
	validates :name, :presence => true
	validates :required_at, :presence => true

	accepts_nested_attributes_for  :properties, reject_if: :all_blank, allow_destroy: true

end

class JobValue < ActiveRecord::Base
  belongs_to :job
  belongs_to :detail
  belongs_to :property, :class_name => "Property", :foreign_key => :property_id
  has_and_belongs_to_many :properties

end


## tables

create_table "details", force: true do |t|
    t.string   "name"
    t.integer  "product_id"
    t.integer  "resource_id"
    t.datetime "created_at"
    t.datetime "updated_at"
    t.string   "required_at"
    t.boolean  "has_other"
    t.boolean  "select_many"
    t.boolean  "yes_no"
end

create_table "job_values", force: true do |t|
    t.integer  "job_id"
    t.integer  "detail_id"
    t.integer  "property_id"
    t.string   "other"
    t.boolean  "select"
    t.datetime "created_at"
    t.datetime "updated_at"
end