models.rb 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. # Created by IntelliJ IDEA.
  2. # User: mrs
  3. # Date: 1/12/16
  4. # Time: 10:46 PM
  5. # To change this template use File | Settings | File Templates.
  6. require 'activerecord-jdbcderby-adapter'
  7. driver = JConfig.query_configuration("db.driver") || "org.apache.derby.jdbc.EmbeddedDriver"
  8. if driver.include? 'mysql'
  9. db = JConfig.query_configuration("db.mysql.database")
  10. user = JConfig.query_configuration('db.user')
  11. pass = JConfig.query_configuration('db.pass')
  12. protocol = JConfig.query_configuration('db.protocol') # e.g. jdbc:mysql://cyberfox.com:3306/
  13. ActiveRecord::Base.establish_connection(adapter: 'jdbc', driver: 'com.mysql.jdbc.Driver', url: "#{protocol}#{db}", username: user, password: pass)
  14. else
  15. ActiveRecord::Base.establish_connection(adapter: 'jdbcderby', database: 'jbdb', username: 'user1', password: 'user1')
  16. end
  17. class Auction < ActiveRecord::Base
  18. has_one :entry
  19. belongs_to :seller
  20. end
  21. class Entry < ActiveRecord::Base
  22. belongs_to :auction
  23. belongs_to :multisnipe
  24. belongs_to :snipe
  25. belongs_to :category
  26. class << self
  27. def instance_method_already_implemented?(method_name)
  28. return true if method_name == "invalid?"
  29. super
  30. end
  31. end
  32. end
  33. class Seller < ActiveRecord::Base
  34. has_many :auctions
  35. end
  36. class Category < ActiveRecord::Base
  37. has_many :entries
  38. end
  39. class Snipe < ActiveRecord::Base
  40. has_one :entry
  41. end
  42. class Multisnipe < ActiveRecord::Base
  43. has_many :entries
  44. end