Has Many Associations As Columns
JoshuaNovak919 opened this issue · 1 comments
JoshuaNovak919 commented
Is there a way to show a has many association as columns in an export? Basically i'm trying to have the user export have a column for each group with the header being the group name and the data being the date the group was created. Is there currently a way to do this?
tommeier commented
Hi joshua,
I'd recommend making a custom method, delegate or use a lambda, or simply using the hash syntax.
eg. (given pages has a 'title')
class Book < ActiveRecord::Base
has_many :pages
delegate :title, :to => :page
comma do
name
description
pages :title => 'This is a custom header for page title'
title
custom_method_title
end
def custom_method_title
pages.find('x).title
end
end
cheers,
Tom