diff --git a/app/models/list.rb b/app/models/list.rb index fca9e80d..6ce74fa8 100644 --- a/app/models/list.rb +++ b/app/models/list.rb @@ -248,7 +248,7 @@ class List end def table_number - @table_number ||= table.number + @table_number ||= table.try(:number).to_i end def active? diff --git a/app/models/order.rb b/app/models/order.rb index 54e88644..7d4ae69e 100644 --- a/app/models/order.rb +++ b/app/models/order.rb @@ -53,7 +53,7 @@ class Order end def table_number - list.table.number + list.table_number end alias table_nr table_number diff --git a/app/models/supplier.rb b/app/models/supplier.rb index 08c94e64..94f43f0f 100644 --- a/app/models/supplier.rb +++ b/app/models/supplier.rb @@ -28,7 +28,7 @@ class Supplier has_many :tables, dependent: :destroy has_many :lists, dependent: :destroy #has_many :lists, through: :tables - has_many :orders + has_many :orders, dependent: :destroy has_many :sections, dependent: :destroy after_create :add_section_on_create diff --git a/app/views/suppliers/lists/index.html.slim b/app/views/suppliers/lists/index.html.slim index 917630e4..a8db1be5 100644 --- a/app/views/suppliers/lists/index.html.slim +++ b/app/views/suppliers/lists/index.html.slim @@ -26,7 +26,7 @@ form#select-date-form action='' method="get" td=show_boolean list.needs_help td=show_boolean list.needs_payment td.timestamp data-time=list.closed_at.try(:utc).try(:iso8601) - td= link_to_if list.table.present?, list.table.try(:number), [:suppliers, list.table] + td= link_to_if list.table.present?, list.table_number, [:suppliers, list.table] td.currency= list.price.present? ? currency(list.price) : '...' td.timestamp data-time=list.created_at.utc.iso8601 td.actions