Gmail Calendar Documents Reader Web more »
Recently Visited Groups | Help | Sign in
Google Groups Home
acts_as_reportable basic questions for relatively complex data model
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  6 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Halfordian Golfer  
View profile  
 More options Jun 10 2009, 9:45 pm
From: Halfordian Golfer <walke...@gmail.com>
Date: Wed, 10 Jun 2009 18:45:14 -0700 (PDT)
Local: Wed, Jun 10 2009 9:45 pm
Subject: acts_as_reportable basic questions for relatively complex data model
Hi,

I have a fairly complex domain that I am trying to report on and am
having
difficulty with report_table.

But, my basic question is about the general use of :include.

model_a has many model_b
model_b has many model_c
model_b has many model_d through model_c

When I do:
model_a.report_table(:all, :include => [:model_b])

I get all the columns of these two models. However, when I do
model_a.report_table(:all, :include => [:model_b, :model_c])

I get an error:
/vendor/rails/activerecord/lib/active_record/association_preload.rb:
115

Can someone help me understand this and how includes should be used in
this situation? I'm curious about the need to make sure about the
inclusion of :id column of one model that is used by another,
especially when it is polymorphic through model 'n'.

Many thanks,

Tim


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Andrew France  
View profile  
 More options Jun 11 2009, 5:16 am
From: Andrew France <andrew+li...@avito.co.uk>
Date: Thu, 11 Jun 2009 10:16:12 +0100
Local: Thurs, Jun 11 2009 5:16 am
Subject: Re: [ruport] acts_as_reportable basic questions for relatively complex data model
Hi Tim,

Halfordian Golfer wrote:
> But, my basic question is about the general use of :include.

> model_a has many model_b
> model_b has many model_c
> model_b has many model_d through model_c

> When I do:
> model_a.report_table(:all, :include => [:model_b])

> I get all the columns of these two models. However, when I do
> model_a.report_table(:all, :include => [:model_b, :model_c])

Model_c is not a relation on model_a, you want a nested include:
:include => {:model_b => {:include => :model_c}}

And if you wanted model_d:
:include => {:model_b => {:include => {:model_c => {:include => :model_d}}}}

Don't ask for the model_d and model_c relations from model_b at the same
level as it will cause duplicates (see many previous messages on list).

> I get an error:
> /vendor/rails/activerecord/lib/active_record/association_preload.rb:
> 115

I'm afraid you'd actually have to give the exception message and a few
more lines of backtrace. I suspect it was along the lines of
"association doesn't exist" though, so never mind if that's the case.

> Can someone help me understand this and how includes should be used in
> this situation? I'm curious about the need to make sure about the
> inclusion of :id column of one model that is used by another,
> especially when it is polymorphic through model 'n'.

I don't know what you mean about the id column.

Hope that helps,
Andrew


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Halfordian Golfer  
View profile  
 More options Jun 11 2009, 8:50 am
From: Halfordian Golfer <walke...@gmail.com>
Date: Thu, 11 Jun 2009 05:50:09 -0700 (PDT)
Local: Thurs, Jun 11 2009 8:50 am
Subject: Re: acts_as_reportable basic questions for relatively complex data model
Hi Andrew,

This is exactly what I was looking for and points me back in the right
direction.

My question about the id's stems from the use of it in various
examples that I may have been reading too much in to. It was looking
like you'd need to ensure the id column was present if it was to be
used as a foreign key in subsequent includes. Its absence causing the
include to fail. Again, most likely, my bad interpretation of the
examples I was looking at.

I'll poke about thus newly armed and see what shakes loose.

Indebted.

Tim

On Jun 11, 3:16 am, Andrew France <andrew+li...@avito.co.uk> wrote:


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Halfordian Golfer  
View profile  
 More options Jun 13 2009, 10:22 am
From: Halfordian Golfer <walke...@gmail.com>
Date: Sat, 13 Jun 2009 07:22:15 -0700 (PDT)
Local: Sat, Jun 13 2009 10:22 am
Subject: Re: acts_as_reportable basic questions for relatively complex data model
Just another quick question on this.

In the example where:

model_a has many model_b through model_c

Do you need to include model_c?

Thanks,

Tim

On Jun 11, 6:50 am, Halfordian Golfer <walke...@gmail.com> wrote:


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Halfordian Golfer  
View profile  
 More options Jun 13 2009, 10:23 am
From: Halfordian Golfer <walke...@gmail.com>
Date: Sat, 13 Jun 2009 07:23:34 -0700 (PDT)
Local: Sat, Jun 13 2009 10:23 am
Subject: Re: acts_as_reportable basic questions for relatively complex data model
Duh. I see that this was answered already. Very helpful!!!

Thanks,

Tim

On Jun 13, 8:22 am, Halfordian Golfer <walke...@gmail.com> wrote:


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Halfordian Golfer  
View profile  
 More options Jun 17 2009, 10:25 am
From: Halfordian Golfer <walke...@gmail.com>
Date: Wed, 17 Jun 2009 07:25:19 -0700 (PDT)
Local: Wed, Jun 17 2009 10:25 am
Subject: Re: acts_as_reportable basic questions for relatively complex data model
Been experimenting with this for a while and still getting an error.
Any thoughts much appreciated.

Here's the line and stack trace.

       @table = ModelA.report_table(:all, :only =>
[:id, :name], :include => {:model_b => {:only => [:name], :include =>
{:model_c => {:only => [:name], :include => :model_d }}}})

Error: /GIT/apollo/vendor/rails/activerecord/lib/active_record/
association_preload.rb:115:in `preload_one_association'/GIT/apollo/
vendor/rails/activerecord/lib/active_record/association_preload.rb:
114:in `each'/GIT/apollo/vendor/rails/activerecord/lib/active_record/
association_preload.rb:114:in `preload_one_association'/GIT/apollo/
vendor/rails/activerecord/lib/active_record/association_preload.rb:
91:in `preload_associations'/GIT/apollo/vendor/rails/activerecord/lib/
active_record/association_preload.rb:99:in `preload_associations'/GIT/
apollo/vendor/rails/activerecord/lib/active_record/
association_preload.rb:93:in `each'/GIT/apollo/vendor/rails/
activerecord/lib/active_record/association_preload.rb:93:in
`preload_associations'/GIT/apollo/vendor/rails/activerecord/lib/
active_record/association_preload.rb:99:in `preload_associations'/GIT/
apollo/vendor/rails/activerecord/lib/active_record/
association_preload.rb:93:in `each'/GIT/apollo/vendor/rails/
activerecord/lib/active_record/association_preload.rb:93:in
`preload_associations'/GIT/apollo/vendor/rails/activerecord/lib/
active_record/association_preload.rb:90:in `preload_associations'/GIT/
apollo/vendor/rails/activerecord/lib/active_record/
association_preload.rb:90:in `each'/GIT/apollo/vendor/rails/
activerecord/lib/active_record/association_preload.rb:90:in
`preload_associations'/GIT/apollo/vendor/rails/activerecord/lib/
active_record/base.rb:1492:in `find_every'/GIT/apollo/vendor/rails/
activerecord/lib/active_record/base.rb:589:in `find'/Library/Ruby/Gems/
1.8/gems/acts_as_reportable-1.1.1/lib/ruport/acts_as_reportable.rb:
166:in `report_table'/GIT/apollo/test/unit/report_test.rb:61:in
`__bind_1245248419_704714'/Library/Ruby/Gems/1.8/gems/thoughtbot-
shoulda-2.10.1/lib/shoulda/context.rb:253:in `call'/Library/Ruby/Gems/
1.8/gems/thoughtbot-shoulda-2.10.1/lib/shoulda/context.rb:253:in
`test: Given an existing Apollo system with devices installed should
create a pdf account report. '/GIT/apollo/vendor/rails/activesupport/
lib/active_support/testing/setup_and_teardown.rb:94:in `__send__'/GIT/
apollo/vendor/rails/activesupport/lib/active_support/testing/
setup_and_teardown.rb:94:in `run'/System/Library/Frameworks/
Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/test/unit/testsuite.rb:
34:in `run'/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/
lib/ruby/1.8/test/unit/testsuite.rb:33:in `each'/System/Library/
Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/test/unit/
testsuite.rb:33:in `run'/System/Library/Frameworks/Ruby.framework/
Versions/1.8/usr/lib/ruby/1.8/test/unit/testsuite.rb:34:in `run'/
System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/
test/unit/testsuite.rb:33:in `each'/System/Library/Frameworks/
Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/test/unit/testsuite.rb:
33:in `run'/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/
lib/ruby/1.8/test/unit/ui/testrunnermediator.rb:46:in `old_run_suite'/
Applications/RubyMine 1.1.app/rb/testing/patch/test/unit/ui/
testrunnermediator.rb:36:in `run_suite'/Applications/RubyMine 1.1.app/
rb/testing/patch/test/unit/ui/teamcity/testrunner.rb:69:in
`start_mediator'/Applications/RubyMine 1.1.app/rb/testing/patch/test/
unit/ui/teamcity/testrunner.rb:57:in `start'/System/Library/Frameworks/
Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/test/unit/ui/
testrunnerutilities.rb:29:in `run'/System/Library/Frameworks/
Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/test/unit/autorunner.rb:
216:in `run'/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/
lib/ruby/1.8/test/unit/autorunner.rb:12:in `run'/System/Library/
Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/test/unit.rb:
278-e:1

On Jun 13, 8:23 am, Halfordian Golfer <walke...@gmail.com> wrote:


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2010 Google