In my Customers_Rewards active admin I currently display columns from the Customer_Rewards and Customer data table, but I also want to display columns (such as store_id) from the Order data table.
ActiveAdmin.register CustomerReward do
menu :parent=>"Customers", :priority=>10, :label=>"Activated Rewards"
index do
selectable_column
column("Customer ID"){|u| u.customer.id }
column("Store ID"){|u| u.order.store_id } #DOES NOT WORK
column("First name"){|u| u.customer.first_name }
column("Last name"){|u| u.customer.last_name }
column("Email"){|u| u.customer.email }
column :reward
column :points_redeemed
column :expires_at
column :redeemed_at
bool_column :is_active
actions
end
_____________________________________________________
class CustomerReward < ActiveRecord::Base
belongs_to :customer
end
class Customer < ActiveRecord::Base
has_many :addresses, :order => 'is_active desc, is_default desc'
has_many :customer_rewards
has_many :orders
end
class Order < ActiveRecord::Base
belongs_to :customer
end
I get an error message of:
undefined method `order' for #<Customer:0x007fb1dc2e3160>
Aucun commentaire:
Enregistrer un commentaire