1

我想使用 Active Admin 从个人资料中访问数据。

配置文件有这个模型:

class Profile < ActiveRecord::Base
  attr_accessible :address, :name, :phone
  belongs_to :user

end

打印(订单)有这个模型:

class Print < ActiveRecord::Base
  ....

  belongs_to :user
  has_one :profile
...
end

两个模型都包含来自 User 模型的 user_id 列。并且打印(订单) print.rb 写为:

ActiveAdmin.register Print, :as => "Order" do

     index do
      column "Document", :document_file_name do |print|
         link_to print.document_file_name, print.document.url
      end
      column "Size", :document_file_size do |print|
            number_to_human_size(print.document_file_size)
      end
      column "Print Status", :is_printing
      column "Deliver Status", :is_delivered
      column "Comments", :comment
      default_actions
     end

     show do
       panel "Invoice" do
        table_for(order.user.profile) do
          column "name" do |profile|
           profile.name
          end
        end
       end
     end

end

我如何从配置文件中获取数据,例如:来自 Active Admin 的地址?

编辑:

我正在分享我的解决方案,因为有人要求它:

sidebar "Customer Details", :only => :show do
   attributes_table_for customer.profile do
      row("Email") { customer.email }
      row("Name") { auto_link customer.profile.name }
      row("Address") { auto_link customer.profile.address }
      row("Phone") { auto_link customer.profile.phone }
    end
 end 
4

1 回答 1

1

尝试这个

column :address do |order|
 order.user.address
end
于 2013-05-22T15:57:56.220 回答