I.e., something along the lines of:
config.columns[:software_packages].search_sql =
"CONCAT(software_packages.name, software_packages.platform.name)"
class SomeThing < ActiveRecord::Base
has_many :outcomes
# add these next 2 so can search on them in field_search
has_many :outcome_types, :through => :outcomes
has_many :categories, :through => :outcomes
end
controller:
config.actions.exclude :search
config.actions << :field_search
#only included in columns to use them for field searching
config.columns.add :outcome_types, :categories
config.list.columns.exclude :outcome_types, :categories
config.create.columns.exclude :outcome_types, :categories
config.update.columns.exclude :outcome_types, :categories
config.show.columns.exclude :outcome_types, :categories
config.columns[:outcome_types].search_sql = 'outcome_types.name'
config.columns[:categories].search_sql = 'project_types.name'
config.columns[:categories].label = 'Outcome Categories'
So you'll have 2 columns on the field search form:
Outcome Types and Outcome Categories
If that works then having a separate controller for the report might be
the easiest solution. If you want to intermingle them this is quite a
bit more work. Since views are read-only you will have have to override
activescaffold's CRUD actions as described below. Plus you forevermore
will have to keep them in sync.
Regards,
Kerry
joelm wrote:
> Hi-
>
> A year ago, you gave this reply to the ActiveScaffold group. I'm
> emailing since I don't know if you'd see an update to such an old
> thread.
> Anyway, I tried to follow your advice, created a view and created an
> model for the view. (The model is empty for now, no
> associations. )
> But when I point my controller at the new model I get:
>
> Mysql::Error: #42S02Table
> 'rgame_development.view_report_grouping_titles' doesn't exist: SHOW
> FIELDS FROM `view_report_grouping_titles`
>
> It seems that with MySql ActiveScaffold can't use a view
> interchangeably with a table.
>
> (The problem I'm really trying to solve is that I want to do a 'group
> by' in my data before reporting, so my plan was to use
> a view to setup the groupby since AS doesn't allow us to pass
> in :group as part of the query.)
>
> Thanks for any advice!
>
> Joel
>
> On Sep 8 2007, 1:11 am, Bonefish <bonefis...@gmail.com> wrote:
>
>> To clarify - that's to get to has_many associations of a parent
>> record. If it's just a belongs to on the parent then you can get to
>> that with a virtual column.
>>
>> On Sep 7, 2:07 pm, Bonefish <bonefish.fo...@gmail.com> wrote:
>>
>>
>>> I think the only way to do that would be adatabaseviewof the parent
>>> and it's associations so that the association data becomes
>>> denormalized. Then the association data can be accessed simply via a
>>> virtual column (since it's now just a column of the parent). Of
>>> course then you'd need different classes for reading versus updating
>>> the data and/or have to do some behind the scenes class substitution
>>> in the CRUD actions. Use theviewclass for list and show but the