George, your patch is ok for Postgres.
I'm using SQLite3 in my project... Have you a patch to use with it?
Tks
On 15 jul, 00:46, "George Gensure" <[EMAIL PROTECTED]> wrote:
> This is an issue related to rails 2.1, not necessarily ActiveScaffold,
> though it can be fixed via a small patch, and this may not apply to
> other database sources than postgres
>
> the :includes parameter no longer automatically joins thehabtmjoin
> table, and must be included instead in the :joins parameter
>
> Enough talk. This patch will correct thehabtmissue.
>
> ==== active_scaffold/lib/constraints.rb ====
> @@ -56,7 +56,11 @@
>
> # association column constraint
> elsif column.association
> - active_scaffold_joins.concat column.includes
> + if column.association.macro == :has_and_belongs_to_many
> + active_scaffold_habtm_joins.concat column.includes
> + else
> + active_scaffold_joins.concat column.includes
> + end
> condition_from_association_constraint(column.association, v)
>
> # regular column constraints
> ==== active_scaffold/lib/finder.rb ====
> @@ -50,6 +50,11 @@
> [EMAIL PROTECTED] ||= []
> end
>
> + attr_writer :active_scaffold_habtm_joins
> + def active_scaffold_habtm_joins
> + [EMAIL PROTECTED] ||= []
> + end
> +
> def all_conditions
> merge_conditions(
> active_scaffold_conditions, # from the search
> modules
> @@ -86,7 +91,7 @@
> # create a general-use options array that's compatible with Rails
> finders
> finder_options = { :order => build_order_clause(options[:sorting]),
> :conditions => all_conditions,
> - :joins => joins_for_collection,
> + :joins => joins_for_finder,
> :include => active_scaffold_joins.empty? ?
> nil : active_scaffold_joins}
>
> # NOTE: we must use :include in the count query, because some
> conditions may reference other tables
> @@ -107,6 +112,17 @@
> pager.page(options[:page])
> end
>
> + def joins_for_finder
> + case joins_for_collection.class
> + when String
> + [ joins_for_collection ]
> + when Array
> + joins_for_collection
> + else
> + []
> + end + active_scaffold_habtm_joins
> + end
> +
> # TODO: this should reside on the model, not the controller
> def merge_conditions(*conditions)
> c = conditions.find_all {|c| not c.nil? and not c.empty? }
>
> Enjoy!
> -George
>
> On Mon, Jul 14, 2008 at 6:06 PM, George Gensure <[EMAIL PROTECTED]> wrote:
> > I'm definitely seeing this, and working on a solution. Will post when
> > I figure this out.
>
> > -George
>
> > On Mon, Jun 30, 2008 at 10:26 AM, Matt Culbreth <[EMAIL PROTECTED]> wrote:
>
> >> Hello,
>
> >> I'm running the latest commit from ActiveScaffold and Rails 2.1, with
> >> PostgreSQL 8.2 as the database. I'm having a problem with a nested
> >> association in a list view on a has_and_belongs_to_many association.
>
> >> My classes are Employee and Tag, and they are eachHABTM. I have a
> >> list of Employees which has an action link for Tags. When the user
> >> clicks this, is should a list of tags associated with that Employee.
> >> It used to do that, but in the newest version I get:
>
> >> ActiveRecord::StatementInvalid in TagsController#table
>
> >> PGError: ERROR: missing FROM-clause entry in subquery for table
> >> "employees_tags"
> >> LINE 1: ...".id, tags."id" AS alias_0 FROM "tags" WHERE
> >> (employees_...
> >> ^
> >> : SELECT * FROM (SELECT DISTINCT ON ("tags".id) "tags".id, tags."id"
> >> AS alias_0 FROM "tags" WHERE (employees_tags.employee_id = E'1') )
> >> AS id_list ORDER BY id_list.alias_0 LIMIT 15 OFFSET 0
>
> >> As you can see there's no "employees_tags" table referenced in the
> >> query.
>
> >> Anybody else seeing this?
>
> >> Thanks,
>
> >> Matt
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---