第一个是本机SQL查询,它正常运行但在活动记录上它没有显示任何关于播放器表的信息。尽管我已授予对Batsman和Player模型文件
的访问权限,但Player.name属性不可见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