2014-03-05 06:40:04 +00:00
|
|
|
module JamRuby
|
|
|
|
|
class PlayablePlay < ActiveRecord::Base
|
|
|
|
|
self.table_name = "playable_plays"
|
|
|
|
|
|
2015-03-23 20:06:32 +00:00
|
|
|
belongs_to :playable, :polymorphic => :true
|
|
|
|
|
# VRFS-2916 jam_tracks.id is varchar: REMOVE
|
2015-03-25 16:11:10 +00:00
|
|
|
#belongs_to :jam_track, :foreign_key => :jam_track_id
|
2014-03-05 06:40:04 +00:00
|
|
|
belongs_to :user, :class_name => "JamRuby::User", :foreign_key => "player_id"
|
|
|
|
|
belongs_to :claimed_recording, :class_name => "JamRuby::ClaimedRecording", :foreign_key => "claimed_recording_id"
|
|
|
|
|
|
2015-03-23 20:06:32 +00:00
|
|
|
validate do
|
|
|
|
|
# VRFS-2916 jam_tracks.id is varchar: REMOVE
|
2015-03-25 16:11:10 +00:00
|
|
|
#if !playable_id && !jam_track_id
|
|
|
|
|
# self.errors[:base] << 'No playable instance detected'
|
|
|
|
|
#end
|
2015-03-23 20:06:32 +00:00
|
|
|
|
|
|
|
|
# VRFS-2916 jam_tracks.id is varchar: ADD
|
2015-03-25 16:11:10 +00:00
|
|
|
if !playable_id
|
|
|
|
|
self.errors[:base] << 'No playable instance detected'
|
|
|
|
|
end
|
2015-03-23 20:06:32 +00:00
|
|
|
|
|
|
|
|
if !user
|
|
|
|
|
self.errors[:base] << 'No user detected'
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
2014-03-05 06:40:04 +00:00
|
|
|
end
|
|
|
|
|
end
|