Add and inherit from ApplicationRecord to match Rails 5.0 style
This commit is contained in:
parent
8c6d48da86
commit
abe847c0ee
34 changed files with 56 additions and 66 deletions
3
app/models/application_record.rb
Normal file
3
app/models/application_record.rb
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
class ApplicationRecord < ActiveRecord::Base
|
||||||
|
self.abstract_class = true
|
||||||
|
end
|
|
@ -1,5 +1,5 @@
|
||||||
# encoding: utf-8
|
# encoding: utf-8
|
||||||
class Article < ActiveRecord::Base
|
class Article < ApplicationRecord
|
||||||
include PriceCalculation
|
include PriceCalculation
|
||||||
|
|
||||||
# @!attribute name
|
# @!attribute name
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
# Article category
|
# Article category
|
||||||
class ArticleCategory < ActiveRecord::Base
|
class ArticleCategory < ApplicationRecord
|
||||||
|
|
||||||
# @!attribute name
|
# @!attribute name
|
||||||
# @return [String] Title of the category.
|
# @return [String] Title of the category.
|
||||||
|
@ -40,4 +40,3 @@ class ArticleCategory < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
class ArticlePrice < ActiveRecord::Base
|
class ArticlePrice < ApplicationRecord
|
||||||
include PriceCalculation
|
include PriceCalculation
|
||||||
|
|
||||||
# @!attribute price
|
# @!attribute price
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
class Assignment < ActiveRecord::Base
|
class Assignment < ApplicationRecord
|
||||||
|
|
||||||
belongs_to :user
|
belongs_to :user
|
||||||
belongs_to :task
|
belongs_to :task
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
class BankAccount < ActiveRecord::Base
|
class BankAccount < ApplicationRecord
|
||||||
|
|
||||||
has_many :bank_transactions, dependent: :destroy
|
has_many :bank_transactions, dependent: :destroy
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
class BankTransaction < ActiveRecord::Base
|
class BankTransaction < ApplicationRecord
|
||||||
|
|
||||||
# @!attribute external_id
|
# @!attribute external_id
|
||||||
# @return [String] Unique Identifier of the transaction within the bank account.
|
# @return [String] Unique Identifier of the transaction within the bank account.
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
class Delivery < ActiveRecord::Base
|
class Delivery < ApplicationRecord
|
||||||
|
|
||||||
belongs_to :supplier
|
belongs_to :supplier
|
||||||
belongs_to :invoice
|
belongs_to :invoice
|
||||||
|
@ -47,5 +47,3 @@ class Delivery < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
class FinancialLink < ActiveRecord::Base
|
class FinancialLink < ApplicationRecord
|
||||||
has_many :bank_transactions
|
has_many :bank_transactions
|
||||||
has_many :financial_transactions
|
has_many :financial_transactions
|
||||||
has_many :invoices
|
has_many :invoices
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
# financial transactions are the foodcoop internal financial transactions
|
# financial transactions are the foodcoop internal financial transactions
|
||||||
# only ordergroups have an account balance and are happy to transfer money
|
# only ordergroups have an account balance and are happy to transfer money
|
||||||
class FinancialTransaction < ActiveRecord::Base
|
class FinancialTransaction < ApplicationRecord
|
||||||
belongs_to :ordergroup
|
belongs_to :ordergroup
|
||||||
belongs_to :user
|
belongs_to :user
|
||||||
belongs_to :financial_link
|
belongs_to :financial_link
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
class FinancialTransactionClass < ActiveRecord::Base
|
class FinancialTransactionClass < ApplicationRecord
|
||||||
has_many :financial_transaction_types, dependent: :destroy
|
has_many :financial_transaction_types, dependent: :destroy
|
||||||
|
|
||||||
validates :name, presence: true
|
validates :name, presence: true
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
class FinancialTransactionType < ActiveRecord::Base
|
class FinancialTransactionType < ApplicationRecord
|
||||||
belongs_to :financial_transaction_class
|
belongs_to :financial_transaction_class
|
||||||
has_many :financial_transactions, dependent: :restrict_with_exception
|
has_many :financial_transactions, dependent: :restrict_with_exception
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
# encoding: utf-8
|
# encoding: utf-8
|
||||||
# Groups organize the User.
|
# Groups organize the User.
|
||||||
# A Member gets the roles from the Group
|
# A Member gets the roles from the Group
|
||||||
class Group < ActiveRecord::Base
|
class Group < ApplicationRecord
|
||||||
include FindEachWithOrder
|
include FindEachWithOrder
|
||||||
include MarkAsDeletedWithName
|
include MarkAsDeletedWithName
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
# A GroupOrder represents an Order placed by an Ordergroup.
|
# A GroupOrder represents an Order placed by an Ordergroup.
|
||||||
class GroupOrder < ActiveRecord::Base
|
class GroupOrder < ApplicationRecord
|
||||||
include FindEachWithOrder
|
include FindEachWithOrder
|
||||||
|
|
||||||
attr_accessor :group_order_articles_attributes
|
attr_accessor :group_order_articles_attributes
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
# A GroupOrderArticle stores the sum of how many items of an OrderArticle are ordered as part of a GroupOrder.
|
# A GroupOrderArticle stores the sum of how many items of an OrderArticle are ordered as part of a GroupOrder.
|
||||||
# The chronologically order of the Ordergroup - activity are stored in GroupOrderArticleQuantity
|
# The chronologically order of the Ordergroup - activity are stored in GroupOrderArticleQuantity
|
||||||
#
|
#
|
||||||
class GroupOrderArticle < ActiveRecord::Base
|
class GroupOrderArticle < ApplicationRecord
|
||||||
|
|
||||||
belongs_to :group_order
|
belongs_to :group_order
|
||||||
belongs_to :order_article
|
belongs_to :order_article
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
# stores the quantity, tolerance and timestamp of an GroupOrderArticle
|
# stores the quantity, tolerance and timestamp of an GroupOrderArticle
|
||||||
# Considers every update of an article-order, so may rows for one group_order_article ar possible.
|
# Considers every update of an article-order, so may rows for one group_order_article ar possible.
|
||||||
|
|
||||||
class GroupOrderArticleQuantity < ActiveRecord::Base
|
class GroupOrderArticleQuantity < ApplicationRecord
|
||||||
|
|
||||||
belongs_to :group_order_article
|
belongs_to :group_order_article
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
require 'digest/sha1'
|
require 'digest/sha1'
|
||||||
|
|
||||||
# Invites are created by foodcoop users to invite a new user into the foodcoop and their order group.
|
# Invites are created by foodcoop users to invite a new user into the foodcoop and their order group.
|
||||||
class Invite < ActiveRecord::Base
|
class Invite < ApplicationRecord
|
||||||
belongs_to :user
|
belongs_to :user
|
||||||
belongs_to :group
|
belongs_to :group
|
||||||
|
|
||||||
|
@ -32,4 +32,3 @@ class Invite < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
class Invoice < ActiveRecord::Base
|
class Invoice < ApplicationRecord
|
||||||
include CustomFields
|
include CustomFields
|
||||||
|
|
||||||
belongs_to :supplier
|
belongs_to :supplier
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
class MailDeliveryStatus < ActiveRecord::Base
|
class MailDeliveryStatus < ApplicationRecord
|
||||||
self.table_name = 'mail_delivery_status'
|
self.table_name = 'mail_delivery_status'
|
||||||
|
|
||||||
belongs_to :user, foreign_key: 'email', primary_key: 'email'
|
belongs_to :user, foreign_key: 'email', primary_key: 'email'
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
class Membership < ActiveRecord::Base
|
class Membership < ApplicationRecord
|
||||||
|
|
||||||
belongs_to :user
|
belongs_to :user
|
||||||
belongs_to :group
|
belongs_to :group
|
||||||
|
@ -13,4 +13,3 @@ class Membership < ActiveRecord::Base
|
||||||
raise I18n.t('model.membership.no_admin_delete') if self.group.role_admin? && self.group.memberships.size == 1 && Group.where(role_admin: true).count == 1
|
raise I18n.t('model.membership.no_admin_delete') if self.group.role_admin? && self.group.memberships.size == 1 && Group.where(role_admin: true).count == 1
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
# encoding: utf-8
|
# encoding: utf-8
|
||||||
#
|
#
|
||||||
class Order < ActiveRecord::Base
|
class Order < ApplicationRecord
|
||||||
attr_accessor :ignore_warnings
|
attr_accessor :ignore_warnings
|
||||||
|
|
||||||
# Associations
|
# Associations
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
# An OrderArticle represents a single Article that is part of an Order.
|
# An OrderArticle represents a single Article that is part of an Order.
|
||||||
class OrderArticle < ActiveRecord::Base
|
class OrderArticle < ApplicationRecord
|
||||||
include FindEachWithOrder
|
include FindEachWithOrder
|
||||||
|
|
||||||
attr_reader :update_global_price
|
attr_reader :update_global_price
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
class OrderComment < ActiveRecord::Base
|
class OrderComment < ApplicationRecord
|
||||||
|
|
||||||
belongs_to :order
|
belongs_to :order
|
||||||
belongs_to :user
|
belongs_to :user
|
||||||
|
@ -6,4 +6,3 @@ class OrderComment < ActiveRecord::Base
|
||||||
validates_presence_of :order_id, :user_id, :text
|
validates_presence_of :order_id, :user_id, :text
|
||||||
validates_length_of :text, :minimum => 3
|
validates_length_of :text, :minimum => 3
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
class PeriodicTaskGroup < ActiveRecord::Base
|
class PeriodicTaskGroup < ApplicationRecord
|
||||||
has_many :tasks, dependent: :destroy
|
has_many :tasks, dependent: :destroy
|
||||||
|
|
||||||
def has_next_task?
|
def has_next_task?
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
class SharedArticle < ActiveRecord::Base
|
class SharedArticle < ApplicationRecord
|
||||||
|
|
||||||
# connect to database from sharedLists-Application
|
# connect to database from sharedLists-Application
|
||||||
SharedArticle.establish_connection(FoodsoftConfig[:shared_lists])
|
SharedArticle.establish_connection(FoodsoftConfig[:shared_lists])
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
class SharedSupplier < ActiveRecord::Base
|
class SharedSupplier < ApplicationRecord
|
||||||
|
|
||||||
# connect to database from sharedLists-Application
|
# connect to database from sharedLists-Application
|
||||||
SharedSupplier.establish_connection(FoodsoftConfig[:shared_lists])
|
SharedSupplier.establish_connection(FoodsoftConfig[:shared_lists])
|
||||||
|
@ -33,4 +33,3 @@ class SharedSupplier < ActiveRecord::Base
|
||||||
methods
|
methods
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
class StockChange < ActiveRecord::Base
|
class StockChange < ApplicationRecord
|
||||||
belongs_to :delivery
|
belongs_to :delivery
|
||||||
belongs_to :order
|
belongs_to :order
|
||||||
belongs_to :stock_taking
|
belongs_to :stock_taking
|
||||||
|
@ -16,4 +16,3 @@ class StockChange < ActiveRecord::Base
|
||||||
stock_article.update_quantity!
|
stock_article.update_quantity!
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
class StockTaking < ActiveRecord::Base
|
class StockTaking < ApplicationRecord
|
||||||
|
|
||||||
has_many :stock_changes, :dependent => :destroy
|
has_many :stock_changes, :dependent => :destroy
|
||||||
has_many :stock_articles, :through => :stock_changes
|
has_many :stock_articles, :through => :stock_changes
|
||||||
|
@ -11,4 +11,3 @@ class StockTaking < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
# encoding: utf-8
|
# encoding: utf-8
|
||||||
class Supplier < ActiveRecord::Base
|
class Supplier < ApplicationRecord
|
||||||
include MarkAsDeletedWithName
|
include MarkAsDeletedWithName
|
||||||
include CustomFields
|
include CustomFields
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
class Task < ActiveRecord::Base
|
class Task < ApplicationRecord
|
||||||
has_many :assignments, :dependent => :destroy
|
has_many :assignments, :dependent => :destroy
|
||||||
has_many :users, :through => :assignments
|
has_many :users, :through => :assignments
|
||||||
belongs_to :workgroup
|
belongs_to :workgroup
|
||||||
|
@ -126,4 +126,3 @@ class Task < ActiveRecord::Base
|
||||||
true
|
true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
require 'digest/sha1'
|
require 'digest/sha1'
|
||||||
# specific user rights through memberships (see Group)
|
# specific user rights through memberships (see Group)
|
||||||
class User < ActiveRecord::Base
|
class User < ApplicationRecord
|
||||||
include CustomFields
|
include CustomFields
|
||||||
#TODO: acts_as_paraniod ??
|
#TODO: acts_as_paraniod ??
|
||||||
|
|
||||||
|
@ -228,4 +228,3 @@ class User < ActiveRecord::Base
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
class Document < ActiveRecord::Base
|
class Document < ApplicationRecord
|
||||||
include ActsAsTree
|
include ActsAsTree
|
||||||
|
|
||||||
belongs_to :created_by, class_name: 'User', foreign_key: 'created_by_user_id'
|
belongs_to :created_by, class_name: 'User', foreign_key: 'created_by_user_id'
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
require "base32"
|
require "base32"
|
||||||
|
|
||||||
class Message < ActiveRecord::Base
|
class Message < ApplicationRecord
|
||||||
belongs_to :sender, :class_name => "User", :foreign_key => "sender_id"
|
belongs_to :sender, :class_name => "User", :foreign_key => "sender_id"
|
||||||
belongs_to :group, :class_name => "Group", :foreign_key => "group_id"
|
belongs_to :group, :class_name => "Group", :foreign_key => "group_id"
|
||||||
belongs_to :reply_to_message, :class_name => "Message", :foreign_key => "reply_to"
|
belongs_to :reply_to_message, :class_name => "Message", :foreign_key => "reply_to"
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
class Page < ActiveRecord::Base
|
class Page < ApplicationRecord
|
||||||
include ActsAsTree
|
include ActsAsTree
|
||||||
|
|
||||||
belongs_to :user, :foreign_key => 'updated_by'
|
belongs_to :user, :foreign_key => 'updated_by'
|
||||||
|
|
Loading…
Reference in a new issue