我想使用Active Admin訪問配置文件中的數據。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_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
如何從配置文件中獲取數據,例如:從主動聯繫地址?
編輯:
我分享我的解決方案,因爲有人要求它:
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
哪個Ruby on Rails的版本,你是什麼意思? – Askar