Allowing SharedSuppliers to have multiple Suppliers. Should fix bennibu#107.

This commit is contained in:
Robert Waltemath 2013-06-04 11:28:25 +02:00
parent 53518039f1
commit c194d2545f
3 changed files with 4 additions and 4 deletions

View file

@ -213,7 +213,7 @@ class ArticlesController < ApplicationController
# fills a form whith values of the selected shared_article # fills a form whith values of the selected shared_article
def import def import
@article = SharedArticle.find(params[:shared_article_id]).build_new_article @article = SharedArticle.find(params[:shared_article_id]).build_new_article(@supplier)
render :action => 'new', :layout => false render :action => 'new', :layout => false
end end

View file

@ -7,8 +7,8 @@ class SharedArticle < ActiveRecord::Base
belongs_to :shared_supplier, :foreign_key => :supplier_id belongs_to :shared_supplier, :foreign_key => :supplier_id
def build_new_article def build_new_article(supplier)
shared_supplier.supplier.articles.build( supplier.articles.build(
:name => name, :name => name,
:unit => unit, :unit => unit,
:note => note, :note => note,

View file

@ -5,7 +5,7 @@ class SharedSupplier < ActiveRecord::Base
# set correct table_name in external DB # set correct table_name in external DB
self.table_name = 'suppliers' self.table_name = 'suppliers'
has_one :supplier has_many :suppliers
has_many :shared_articles, :foreign_key => :supplier_id has_many :shared_articles, :foreign_key => :supplier_id
end end