diff --git a/ruby/lib/jam_ruby/models/band.rb b/ruby/lib/jam_ruby/models/band.rb index 47ba88455..500b7eab3 100644 --- a/ruby/lib/jam_ruby/models/band.rb +++ b/ruby/lib/jam_ruby/models/band.rb @@ -3,10 +3,10 @@ module JamRuby include HtmlSanitize html_sanitize strict: [:biography, :website, :name] - attr_accessible :name, :website, :biography, :city, :state, + attr_accessible :name, :website, :biography, :city, :state, :country, :original_fpfile_photo, :cropped_fpfile_photo, :cropped_large_fpfile_photo, :cropped_s3_path_photo, :cropped_large_s3_path_photo, :crop_selection_photo, :photo_url, :large_photo_url, - :band_type, :band_status, :concert_count, :add_new_members, :play_commitment, :touring_option, :paid_gigs, + :band_type, :band_status, :concert_count, :add_new_members, :play_commitment, :touring_option, :paid_gigs, :free_gigs, :hourly_rate, :gig_minimum attr_accessor :updating_photo, :skip_location_validation, :skip_genre_validation @@ -181,7 +181,7 @@ module JamRuby band = id.blank? ? Band.new : Band.find(id) # ensure user updating Band details is a Band member - unless band.new_record? || band.users.exists?(user) + unless band.new_record? || band.users.exists?(user) raise JamPermissionError, ValidationMessages::USER_NOT_BAND_MEMBER_VALIDATION_ERROR end @@ -205,15 +205,17 @@ module JamRuby band.concert_count = params[:concert_count] if params.has_key?(:concert_count) band.play_commitment = params[:play_commitment] if params.has_key?(:play_commitment) - if params.has_key?(:genres) && params[:genres] + if params[:validate_genres] # loop through each genre in the array and save to the db genres = [] - params[:genres].each { |genre_id| genres << Genre.find(genre_id) } + params[:genres].each { |genre_id| genres << Genre.find(genre_id) } if params[:genres].present? band.genres = genres + band.skip_genre_validation = false + else + params[:validate_genres] + band.skip_genre_validation = true end - band.skip_genre_validation = true unless params[:validate_genres] - unless band.new_record? OnlinePresence.delete_all(["player_id = ?", band.id]) PerformanceSample.delete_all(["player_id = ?", band.id]) @@ -222,7 +224,7 @@ module JamRuby online_presences = params[:online_presences] if online_presences.present? online_presences.each do |op| - new_presence = OnlinePresence.create(band, op, false) + new_presence = OnlinePresence.create(band, op, false) band.online_presences << new_presence end end @@ -230,15 +232,15 @@ module JamRuby performance_samples = params[:performance_samples] if performance_samples.present? performance_samples.each do |ps| - band.performance_samples << PerformanceSample.create(band, ps, false) + band.performance_samples << PerformanceSample.create(band, ps, false) end end - + band end # helper method for creating / updating a Band - def self.save(user, params) + def self.save(user, params) band = build_band(user, params) if band.save @@ -296,7 +298,7 @@ module JamRuby def check_lat_lng if (city_changed? || state_changed? || country_changed?) - update_lat_lng + update_lat_lng end true end