0

When using Ruport to make a CSV file for entities containing the same entities, the generated column names create conflicts, causing Ruport to show only the first occurence of this column(s). To make this abstract explanation more clear and less complicated, an example:

My class Zone inherits from ServerUnitConfig, which has a :belongs_to to a ServerUnit. So Zone has for example server_unit.su_name as a field. Zone also has a :belongs_to for Domain, which also inherits from ServerUnitConfig.

I want both to be included in my Ruport and to do this I have the following :include argument for my report_table of Ruport:

{            
    :server_unit => {:only => 'su_name'}, 
    :domain => {:include => {:server_unit => {:only => 'su_name'}}, :only => {}
}

Reporting this with Ruport in a CSV file, gives a report showing only the server_unit.su_name column of server_unit not the one of Domain. Normally also the server_unit.su_name should be shown, but since Ruport only shows the field name and its parent, both cases show server_unit.su_name and this gives conflicts.

I would suggest to give a custom name to the field in the include, but I don't know how. An other idea, if it would be possible, is to tell Ruport one or the other way it is no problem to have identical column names, but I don't think that is possible. Has anybody an idea to solve this problem? It would help me a lot!

Thanks

Daan

mu is too short
  • 426,620
  • 70
  • 833
  • 800
Daan
  • 3
  • 2

1 Answers1

0

You could use the report_table_by_sql method, which is a bit ugly. Or use the :method option to call a method with a slightly different name, not great either.

There is a :qualify_attribute_names option for each include that was used internally. I've written a patch here: https://gist.github.com/1057518 that will expose it, you can use it like so:

{:server_unit => {:qualify_attribute_names => 'serv', :only => 'su_name'}}

To apply the patch you'd need to "vendor" the acts_as_reportable gem in Rails, which can be a pain. I'll try and put it on the main repo at https://github.com/ruport/acts_as_reportable soon when I'm sure it has no problems.

Hope that helps, Andrew

Andrew France
  • 4,758
  • 1
  • 25
  • 27
  • I already found out that methods are indeed an option and so I solved it this way. Your :qualify_attribute_names could be a useful addition to the code. It's still a lot of work for the slight difference it makes, but it could still come in handy. It does the same as methods I suppose, but in an a lot cleaner way. Thx... and Keep me informed about your plug-in. – Daan Jul 01 '11 at 08:56