I would like to access the data from the Profile using Active Admin.
Profile has this model:
class Profile < ActiveRecord::Base
attr_accessible :address, :name, :phone
belongs_to :user
end
Print (orders) has this model:
class Print < ActiveRecord::Base
....
belongs_to :user
has_one :profile
...
end
Both models have user_id column in it, from the User model. and the Print (Orders) print.rb is written as:
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
How do i get the data from profile, for example, :address from Active Admin?
EDIT:
I am sharing my solution since someone requested for it:
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