내 DB 스키마 가입하나 개의 테이블을 두 번
class Tournament < ActiveRecord::Base
has_many :teams, dependent: :destroy
has_many :matches, dependent: :destroy
...
end
class Team < ActiveRecord::Base
belongs_to :tournament
...
end
class Match < ActiveRecord::Base
belongs_to :tournament
has_many :teams
...
end
내가보기에 다음과 같은 데이터 싶은
: 그래서
match_id team_id_home team_id_away team_id_home_name team_id_away_name
을, I 다음 질문에 대한 도움을 요청합니다. (팀 이름을 얻으려고하는데 합류하는데 문제가 있습니다) :
@matches = @tournament.matches.where(:tournament => @tournament).joins(:teams).paginate(page: params[:page])
오류를 tournament.home_team.name을 사용할 수 없습니다 이러한 열 : teams.team_id_home를 "팀"SELECT * "팀" "팀의. "."team_id_home "=? ORDER BY "teams". "id"ASC LIMIT 1 – davor