Merge branch 'rails3-allow-multiple-suppliers' of git://github.com/foodcoop-rostock/foodsoft into foodcoop-rostock-rails3-allow-multiple-suppliers

This commit is contained in:
Benjamin Meichsner 2013-06-12 10:40:20 +02:00
commit 25fbb47320
4 changed files with 8 additions and 6 deletions

View File

@ -206,7 +206,7 @@ class ArticlesController < ApplicationController
# fills a form whith values of the selected shared_article
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
end

View File

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

View File

@ -5,7 +5,7 @@ class SharedSupplier < ActiveRecord::Base
# set correct table_name in external DB
self.table_name = 'suppliers'
has_one :supplier
has_many :suppliers
has_many :shared_articles, :foreign_key => :supplier_id
# These set of attributes are used to autofill attributes of new supplier,

View File

@ -22,7 +22,9 @@
%td= shared_supplier.note
%td= shared_supplier.delivery_days
%td
- if shared_supplier.supplier
- if shared_supplier.suppliers
%i.icon-ok
= '(' + shared_supplier.suppliers.map{|s| s.name}.join(', ') + ')'
= link_to "abonnieren", new_supplier_path(:shared_supplier_id => shared_supplier), class: 'btn'
- else
= link_to "abonnieren", new_supplier_path(:shared_supplier_id => shared_supplier), class: 'btn'
= link_to "abonnieren", new_supplier_path(:shared_supplier_id => shared_supplier), class: 'btn'