Add stock_article_selection (deleting multiple stock articles at once)
This commit is contained in:
parent
ecb7ce7cd3
commit
099e2b9b06
13 changed files with 217 additions and 34 deletions
24
app/models/stock_article_selection.rb
Normal file
24
app/models/stock_article_selection.rb
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
# encoding: utf-8
|
||||
class StockArticleSelection < ActiveRecord::Base
|
||||
|
||||
# Associations
|
||||
has_and_belongs_to_many :stock_articles
|
||||
belongs_to :created_by, :class_name => 'User', :foreign_key => 'created_by_user_id'
|
||||
belongs_to :finished_by, :class_name => 'User', :foreign_key => 'finished_by_user_id'
|
||||
|
||||
# Validations
|
||||
validate :include_stock_articles
|
||||
|
||||
def all_articles
|
||||
all_articles = stock_article_ids
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
def include_stock_articles
|
||||
errors.add(:stock_articles, "Es muss mindestens ein Lagerartikel ausgewählt sein.") if stock_articles.empty?
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue