joelm wrote:
> I'm trying to generate a report with a top level that is grouped. It
> appears from previous threads that the best solution is to create a
> view since there is no way to specify Group By (:group) in AS's find_
> methods. That works to some level.
>
> But this fails if I need to winnow down the records BEFORE the group
> by.
>
> i.e. SELECT * FROM info GROUP BY type
>
> works fine. But what I really want is:
> SELECT * FROM info WHERE user_id = current_user.id GROUP BY type
>
> current_user.id is dynamic and in a stored procedure would be a
> parameter.
>
> If I had control of the find method, this should work fine since
> the :conditions => {user_id = current_user.id}
> would be added to the SQL and be executed BEFORE the group by by the
> database engine.
>
> But, in a view, I would have to write:
> create view 'testView' => "SELECT * FROM info GROUP BY type"
>
> Presuming that there are many records of the same 'type' from
> different 'users', the user_id
> value in that view is indeterminate, so I can't use it as a
> condition. If my view were to be:
> "SELECT * FROM info GROUP BY user_id, type"
>
> Then I could filter out the user_id's I want, but I'd then be left
> with multiple rows for each 'type'.
> (That is, all the remaining users.)
>
>
> So, the real question: Is there ANY way to add a :group clause to the
> AS search? Or allow me to
> substitute in my own SQL for the search or does anyone have some
> solution that I'm missing?
> (And is there a reason that AS does NOT allow :group? i.e. is there a
> fundamental reason this shouldn't work or is it just an implementation
> issue of
> too many things that need doing?
>
>
Patch the code?
Ed W
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"ActiveScaffold : Ruby on Rails plugin" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/activescaffold?hl=en
-~----------~----~----~----~------~----~------~--~---