0

我有两个模型:UserDog. 我希望能够在单个 Datagrid 报告中显示它们。使用该方法时,我使用什么语法来引用用户模型的特定属性column()?现在我只是显示对象,User但我想显示模型的各种列:name和属性。:gender:ageUser

class User < ActiveRecord::Base
  attr_accessible :email, :age, :gender, :name
  has_many :dogs

class Dog < ActiveRecord::Base
  attr_accessible :name, :age
  belongs_to :user

class DogReport
    include Datagrid

  #
  # Scope
  #

  scope do
    Dog.includes(:user)
  end

  #
  # Filters
  #

  filter(:dog_id, :integer)

  #
  # Columns
  #

  column(:id)
  column(:name)
  column(:age)
  column(:user)
end
4

1 回答 1

0
column(:user, :header => "user.name") do
  self.user.name
end
于 2012-12-05T20:49:44.003 回答