Displaying 1 result from an estimated 1 matches for "show_contest".
2006 Jun 09
0
Calculations based on multiple tables
...er
has_many :contest_entries, :dependent => true
end
class Member < ActiveRecord::Base
has_many :songs, :order => :position
end
------------------------
This is what I''m currently doing to perform the average on each song, but it
seems like there should be a better way.
def show_contest
@contest = Contest.find(params[:id])
@contest_entries = ContestEntry.find_all_by_contest_id(@contest.id)
@contest_entries.each do |contest_entry|
songs = ContestRating.find_all_by_contest_entry_id
(contest_entry.id.to_s)
total = 0
songs.each do |song|
total +=...