I currently have 3 tables/models: 1) Clients, 2) Charges, and 3) Court_Dates. Clients 1..n Charges 1..n Court_Dates I am trying to find all clients that have a court_date on a certain day: something along the lines of (@client.charge.court_date.date == Date.today). I have had success preloading child rows using the :include parameter, but that only works with a parent and a child, or a parent with multiple children, but not with a parent who has a child that acts as a parent to another child. I don''t know if that makes any sense, but I would like to preload 2 levels deep. Any thoughts/suggestions greatly appreciated? -- Posted via http://www.ruby-forum.com/.
Listening ... On Thu, 2006-03-09 at 10:00 +0100, Justin Copeland wrote:> I currently have 3 tables/models: 1) Clients, 2) Charges, and 3) > Court_Dates. > Clients 1..n Charges 1..n Court_Dates >...> I don''t know if that makes any sense, but I would like to preload 2 > levels deep. Any thoughts/suggestions greatly appreciated? >
On 3/9/06, Justin Copeland <copeland.justin@gmail.com> wrote:> I don''t know if that makes any sense, but I would like to preload 2 > levels deep. Any thoughts/suggestions greatly appreciated?Wait for Rails 1.1, which will include support for what you want, or use Edge Rails if you must have the feature now.
Jeremy Evans wrote:> On 3/9/06, Justin Copeland <copeland.justin@gmail.com> wrote: >> I don''t know if that makes any sense, but I would like to preload 2 >> levels deep. Any thoughts/suggestions greatly appreciated? > > Wait for Rails 1.1, which will include support for what you want, or > use Edge Rails if you must have the feature now.well that is not what i wanted to hear. when is rails 1.1 due out, soon i hope? And what is the story with EdgeRails? I do not know much about it. -- Posted via http://www.ruby-forum.com/.
On 3/9/06, Justin Copeland <copeland.justin@gmail.com> wrote:> And what is the story with EdgeRails?http://wiki.rubyonrails.com/rails/pages/EdgeRails
Jeremy Evans wrote:> On 3/9/06, Justin Copeland <copeland.justin@gmail.com> wrote: >> I don''t know if that makes any sense, but I would like to preload 2 >> levels deep. Any thoughts/suggestions greatly appreciated? > > Wait for Rails 1.1, which will include support for what you want, or > use Edge Rails if you must have the feature now.I have Edge Rails, how do I do this? -- Posted via http://www.ruby-forum.com/.
i think you want to use the :through paramater.. Not sure how it works though. Search the forum and i think you will find some help on it. adam On 3/9/06, Nathan Ventura <nathanlb@shaw.ca> wrote:> > Jeremy Evans wrote: > > On 3/9/06, Justin Copeland <copeland.justin@gmail.com> wrote: > >> I don''t know if that makes any sense, but I would like to preload 2 > >> levels deep. Any thoughts/suggestions greatly appreciated? > > > > Wait for Rails 1.1, which will include support for what you want, or > > use Edge Rails if you must have the feature now. > > I have Edge Rails, how do I do this? > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060310/ffa7eac3/attachment.html
Jeremy Evans wrote:>> I currently have 3 tables/models: 1) Clients, 2) Charges, and 3) >> Court_Dates. >> Clients 1..n Charges 1..n Court_Dates >> >> I am trying to find all clients that have a court_date on a certain day: >> something along the lines of (@client.charge.court_date.date == >> Date.today). >> >> I have had success preloading child rows using the :include parameter, >> but that only works with a parent and a child, or a parent with multiple >> children, but not with a parent who has a child that acts as a parent to >> another child. >> I don''t know if that makes any sense, but I would like to preload 2 >> levels deep. Any thoughts/suggestions greatly appreciated? > > Wait for Rails 1.1, which will include support for what you want, or > use Edge Rails if you must have the feature now.I don''t have to do it that way. I''d rather not mess with Edge Rails right now, hopefully 1.1 hits the streets soon?. Is there another way to accomplish basically the same thing? -- Posted via http://www.ruby-forum.com/.
Find_by_sql :) Maybe you can just write the sql statement to get your results. I don''t know your table relationships so I really can''t say if that would work for you or not. I had project ->tasks ->time and I was able to get a list of all hours logged for a project for all tasks using find_by_sql. Hope that helps! -----Original Message----- From: rails-bounces@lists.rubyonrails.org [mailto:rails-bounces@lists.rubyonrails.org] On Behalf Of Justin Copeland Sent: Friday, March 10, 2006 8:09 AM To: rails@lists.rubyonrails.org Subject: [Rails] Re: Preloading child rows 2 levels deep? Jeremy Evans wrote:>> I currently have 3 tables/models: 1) Clients, 2) Charges, and 3) >> Court_Dates. >> Clients 1..n Charges 1..n Court_Dates >> >> I am trying to find all clients that have a court_date on a certain >> day: >> something along the lines of (@client.charge.court_date.date == >> Date.today). >> >> I have had success preloading child rows using the :include >> parameter, >> but that only works with a parent and a child, or a parent withmultiple>> children, but not with a parent who has a child that acts as a parentto>> another child. >> I don''t know if that makes any sense, but I would like to preload 2 >> levels deep. Any thoughts/suggestions greatly appreciated? > > Wait for Rails 1.1, which will include support for what you want, or > use Edge Rails if you must have the feature now.I don''t have to do it that way. I''d rather not mess with Edge Rails right now, hopefully 1.1 hits the streets soon?. Is there another way to accomplish basically the same thing? -- Posted via http://www.ruby-forum.com/. _______________________________________________ Rails mailing list Rails@lists.rubyonrails.org http://lists.rubyonrails.org/mailman/listinfo/rails
Charles M. Gerungan
2006-Mar-10 15:51 UTC
[Rails] Re: Preloading child rows 2 levels deep?
On 10-mrt-2006, at 15:08, Justin Copeland wrote:>> Wait for Rails 1.1, which will include support for what you want, or >> use Edge Rails if you must have the feature now. > > I don''t have to do it that way. I''d rather not mess with Edge Rails > right now, hopefully 1.1 hits the streets soon?. Is there another > way to > accomplish basically the same thing?Messing with edge rails is just: 1. rake freeze_edge 2. sudo gem update rake (if you''re not at 0.7 yet) 3. there is no step 3 :) Then, if you want to get rid of edge rails, just rm -rf RAILS_ROOT/ vendor/rails. And what you want is just a syntax change of :include away! -- Regards, Charles.
On 3/9/06, Nathan Ventura <nathanlb@shaw.ca> wrote:> Jeremy Evans wrote: > > On 3/9/06, Justin Copeland <copeland.justin@gmail.com> wrote: > >> I don''t know if that makes any sense, but I would like to preload 2 > >> levels deep. Any thoughts/suggestions greatly appreciated? > > > > Wait for Rails 1.1, which will include support for what you want, or > > use Edge Rails if you must have the feature now. > > I have Edge Rails, how do I do this?I haven''t used the feature, but it supposedly works like this: Client.find(:all, :include=>{:charges=>:court_dates}) See http://dev.rubyonrails.org/ticket/3913.
Justin Copeland
2006-Mar-11 00:06 UTC
[Rails] Re: Re: Preloading child rows 2 levels deep?
Charles M. Gerungan wrote:> On 10-mrt-2006, at 15:08, Justin Copeland wrote: > >>> Wait for Rails 1.1, which will include support for what you want, or >>> use Edge Rails if you must have the feature now. >> >> I don''t have to do it that way. I''d rather not mess with Edge Rails >> right now, hopefully 1.1 hits the streets soon?. Is there another >> way to >> accomplish basically the same thing? > > Messing with edge rails is just: > > 1. rake freeze_edge > 2. sudo gem update rake (if you''re not at 0.7 yet) > 3. there is no step 3 :) > > Then, if you want to get rid of edge rails, just rm -rf RAILS_ROOT/ > vendor/rails. > > And what you want is just a syntax change of :include away! > > -- > Regards, Charles.Well when you put it that way... maybe I will mess with it! Thanks for the help. Everyone on here is so helpful, I really enjoy this community. -- Posted via http://www.ruby-forum.com/.
Justin Copeland
2006-Mar-11 01:17 UTC
[Rails] Re: Re: Preloading child rows 2 levels deep?
Justin Copeland wrote:> Charles M. Gerungan wrote: >> On 10-mrt-2006, at 15:08, Justin Copeland wrote: >> >>>> Wait for Rails 1.1, which will include support for what you want, or >>>> use Edge Rails if you must have the feature now. >>> >>> I don''t have to do it that way. I''d rather not mess with Edge Rails >>> right now, hopefully 1.1 hits the streets soon?. Is there another >>> way to >>> accomplish basically the same thing? >> >> Messing with edge rails is just: >> >> 1. rake freeze_edge >> 2. sudo gem update rake (if you''re not at 0.7 yet) >> 3. there is no step 3 :) >> >> Then, if you want to get rid of edge rails, just rm -rf RAILS_ROOT/ >> vendor/rails. >> >> And what you want is just a syntax change of :include away! >> >> -- >> Regards, Charles. > > Well when you put it that way... maybe I will mess with it! Thanks for > the help. Everyone on here is so helpful, I really enjoy this community.switched to EdgeRails and now the webrick server won''t start under win32: => Booting WEBrick... ./script/../config/../vendor/rails/activesupport/lib/active_support/core_ext/kernel/agnostics.rb:7:in ``'': Exec format error - rake tmp:create (Errno::ENOEXEC) from ./script/../config/../vendor/rails/activesupport/lib/active_support/core_ext/kernel/agnostics.rb:7:in ``'' from ./script/../config/../vendor/rails/railties/lib/commands/server.rb:28 from ./script/../config/../vendor/rails/railties/lib/commands/server.rb:28:in `silence_stderr'' from ./script/../config/../vendor/rails/activesupport/lib/active_support/core_ext/kernel/reporting.rb:26:in `silence_stream'' from ./script/../config/../vendor/rails/activesupport/lib/active_support/core_ext/kernel/reporting.rb:26:in `silence_stderr'' from ./script/../config/../vendor/rails/railties/lib/commands/server.rb:28 from c:/webdev/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:18:in `require__'' from c:/webdev/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:18:in `require'' from ./script/server:3 from -e:3:in `load'' from -e:3 -- Posted via http://www.ruby-forum.com/.
Justin Copeland
2006-Mar-11 05:08 UTC
[Rails] Re: Re: Preloading child rows 2 levels deep?
Justin Copeland wrote:> Justin Copeland wrote: >> Charles M. Gerungan wrote: >>> On 10-mrt-2006, at 15:08, Justin Copeland wrote: >>> >>>>> Wait for Rails 1.1, which will include support for what you want, or >>>>> use Edge Rails if you must have the feature now. >>>> >>>> I don''t have to do it that way. I''d rather not mess with Edge Rails >>>> right now, hopefully 1.1 hits the streets soon?. Is there another >>>> way to >>>> accomplish basically the same thing? >>> >>> Messing with edge rails is just: >>> >>> 1. rake freeze_edge >>> 2. sudo gem update rake (if you''re not at 0.7 yet) >>> 3. there is no step 3 :) >>> >>> Then, if you want to get rid of edge rails, just rm -rf RAILS_ROOT/ >>> vendor/rails.>>>>>> And what you want is just a syntax change of :include away! >>> >>> -- >>> Regards, Charles. >> >> Well when you put it that way... maybe I will mess with it! Thanks for >> the help. Everyone on here is so helpful, I really enjoy this community. > > switched to EdgeRails and now the webrick server won''t start under > win32: > > => Booting WEBrick... > ./script/../config/../vendor/rails/activesupport/lib/active_support/core_ext/kernel/agnostics.rb:7:in > ``'': Exec format error - rake tmp:create (Errno::ENOEXEC) > from > ./script/../config/../vendor/rails/activesupport/lib/active_support/core_ext/kernel/agnostics.rb:7:in > ``'' > from > ./script/../config/../vendor/rails/railties/lib/commands/server.rb:28 > from > ./script/../config/../vendor/rails/railties/lib/commands/server.rb:28:in > `silence_stderr'' > from > ./script/../config/../vendor/rails/activesupport/lib/active_support/core_ext/kernel/reporting.rb:26:in > `silence_stream'' > from > ./script/../config/../vendor/rails/activesupport/lib/active_support/core_ext/kernel/reporting.rb:26:in > `silence_stderr'' > from > ./script/../config/../vendor/rails/railties/lib/commands/server.rb:28 > from > c:/webdev/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:18:in > `require__'' > from > c:/webdev/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:18:in > `require'' > from ./script/server:3 > from -e:3:in `load'' > from -e:3Nevermind, got it fixed by: 1) Upgrading to Ruby 1.8.4 from 1.8.2 2) Upgrading Engines http://rails-engines.org/wiki/pages/Using+Engines+with+Edge+Rails 3) commenting out line 28 of vendor\rails\railties\lib\commands\server.rb #silence_stderr { `rake tmp:create` } Now: Client.find(:all, :include => {:charges => :court_dates}, :conditions => ["date = ?", Date.today] works like champ!! Just what I needed. -- Posted via http://www.ruby-forum.com/.
Now what if the charges has court_dates and a charge_type? This doesnt work: Client.find(:all, :include => {:charges => :court_dates,:charges=>:charge_type}, :conditions => ["date = ?", Date.today] neither does this : Client.find(:all, :include => {:charges => {:court_dates,:charge_type}}, :conditions => ["date = ?", Date.today] Any ideas? -- Posted via http://www.ruby-forum.com/.
so its loading 2 child types 2 levels deep, is it possible? -- Posted via http://www.ruby-forum.com/.
Chris wrote:> Now what if the charges has court_dates and a charge_type? This doesnt > work: > > Client.find(:all, :include => {:charges => > :court_dates,:charges=>:charge_type}, :conditions => ["date = ?", > Date.today] > > neither does this : > > Client.find(:all, :include => {:charges => {:court_dates,:charge_type}}, > :conditions => ["date = ?", Date.today] > > Any ideas?Not got access to ruby in front of me to test this but I think the following will achieve what your after: Client.find(:all, :include => {:charges => [:court_dates,:charge_type]}, :conditions => ["date = ?". Date.today]) Hope this helps you. Assuming i got it right :D -- Posted via http://www.ruby-forum.com/.