added stuff to support getting the max_score attribute to client via json

This commit is contained in:
Scott Comer 2014-03-05 22:26:17 -06:00
parent b54e7d1ca1
commit 20cd9e5dd0
2 changed files with 11 additions and 2 deletions

View File

@ -2,7 +2,7 @@ module JamRuby
class MusicSession < ActiveRecord::Base
self.primary_key = 'id'
attr_accessor :legal_terms, :skip_genre_validation
attr_accessor :legal_terms, :skip_genre_validation, :max_score
attr_accessible :creator, :description, :musician_access, :approval_required, :fan_chat, :fan_access, :genres
belongs_to :creator, :inverse_of => :music_sessions, :class_name => "JamRuby::User", :foreign_key => "user_id"
@ -43,6 +43,15 @@ module JamRuby
#default_scope :select => "*, 0 as score"
def attributes
super.merge('max_score' => self.max_score)
end
def max_score
nil unless has_attribute?(:max_score)
read_attribute(:max_score).to_i
end
before_create :create_uuid
def create_uuid
#self.id = SecureRandom.uuid

View File

@ -13,7 +13,7 @@ if !current_user
}
else
attributes :id, :description, :musician_access, :approval_required, :fan_access, :fan_chat, :band_id, :user_id, :claimed_recording_initiator_id, :track_changes_counter
attributes :id, :description, :musician_access, :approval_required, :fan_access, :fan_chat, :band_id, :user_id, :claimed_recording_initiator_id, :track_changes_counter, :max_score
node :genres do |item|
item.genres.map(&:description)