foodsoft/app/models/shared_article.rb

27 lines
770 B
Ruby
Raw Normal View History

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(FoodsoftConfig[:shared_lists])
2009-01-06 11:49:19 +01:00
# set correct table_name in external DB
2012-10-19 01:12:47 +02:00
self.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