第一个是本地 SQL 查询,它运行良好,但在活动记录中它没有显示任何关于玩家表的内容。Player.name 属性不可见,尽管我已授予对 Batsman 和 Player 模型文件的访问权限
SELECT
players.name, batsmen.*
FROM
batsmen
INNER JOIN
players ON players.id = batsmen.player_id
WHERE
league_id = 13
Batsman.joins(:player).where('league_id = ?',13).select('players.name')
这里是模型
class Batsman < ActiveRecord::Base attr_accessible :fours,:name, :siz, :ave,:batsmenViaLeagues, :match, :league_id, :bestf, :fifty, :hights, :hundred, :innings, :nout, :player_id, :runs, :sr, :zero belongs_to :player has_many :leagues
class Player < ActiveRecord::Base
attr_accessible :image, :name end