2012-01-30 20:39:34 +00:00
|
|
|
# -*- encoding : utf-8 -*-
|
2011-04-11 09:35:08 +01:00
|
|
|
class Product < ActiveRecord::Base
|
2012-12-07 11:11:12 +00:00
|
|
|
include Modules::Models::TimeLiving
|
|
|
|
|
2011-04-11 09:35:08 +01:00
|
|
|
belongs_to :platform
|
2012-11-06 14:13:16 +00:00
|
|
|
belongs_to :project
|
2011-11-11 17:13:09 +00:00
|
|
|
has_many :product_build_lists, :dependent => :destroy
|
2011-04-11 09:35:08 +01:00
|
|
|
|
2011-11-24 21:46:19 +00:00
|
|
|
validates :name, :presence => true, :uniqueness => {:scope => :platform_id}
|
2012-11-13 10:31:45 +00:00
|
|
|
validates :project_id, :presence => true
|
2011-04-14 08:23:08 +01:00
|
|
|
|
2011-04-11 17:55:52 +01:00
|
|
|
scope :recent, order("name ASC")
|
2011-04-14 08:23:08 +01:00
|
|
|
|
2012-11-13 10:31:45 +00:00
|
|
|
attr_accessible :name,
|
|
|
|
:description,
|
|
|
|
:project_id,
|
|
|
|
:main_script,
|
2012-12-07 11:11:12 +00:00
|
|
|
:params
|
2012-04-03 13:21:39 +01:00
|
|
|
attr_readonly :platform_id
|
|
|
|
|
2012-02-21 21:27:11 +00:00
|
|
|
def full_clone(attrs = {})
|
2012-06-08 18:37:16 +01:00
|
|
|
dup.tap do |c|
|
2012-02-22 20:24:29 +00:00
|
|
|
c.platform_id = nil
|
|
|
|
attrs.each {|k,v| c.send("#{k}=", v)}
|
2012-06-08 18:37:16 +01:00
|
|
|
c.updated_at = nil; c.created_at = nil
|
2011-11-03 00:32:01 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2011-04-11 09:35:08 +01:00
|
|
|
end
|