foodsoft/app/models/shared_article.rb

51 lines
1.5 KiB
Ruby
Raw Normal View History

# == Schema Information
# Schema version: 20090102171850
#
# Table name: articles
#
# id :integer(4) not null, primary key
# name :string(255) not null
# supplier_id :integer(4) not null
# number :string(255)
# note :string(255)
# manufacturer :string(255)
# origin :string(255)
# unit :string(255)
# price :decimal(8, 2) default(0.0), not null
# tax :decimal(3, 1) default(7.0), not null
# deposit :decimal(8, 2) default(0.0), not null
# unit_quantity :decimal(4, 1) default(1.0), not null
# scale_quantity :decimal(4, 2)
# scale_price :decimal(8, 2)
# created_on :datetime
# updated_on :datetime
# list :string(255)
#
2009-01-06 11:49:19 +01:00
class SharedArticle < ActiveRecord::Base
2009-01-06 11:49:19 +01:00
# connect to database from sharedLists-Application
SharedArticle.establish_connection(Foodsoft.config[:shared_lists])
2009-01-06 11:49:19 +01:00
# set correct table_name in external DB
set_table_name :articles
2009-01-06 11:49:19 +01:00
belongs_to :shared_supplier, :foreign_key => :supplier_id
def build_new_article
shared_supplier.supplier.articles.build(
:name => name,
:unit => unit,
:note => note,
:manufacturer => manufacturer,
:origin => origin,
:price => price,
:tax => tax,
:deposit => deposit,
:unit_quantity => unit_quantity,
:order_number => number,
# convert to db-compatible-string
:shared_updated_on => updated_on.to_formatted_s(:db)
)
end
2009-01-06 11:49:19 +01:00
end