similar to: eager loading has_one fix

Displaying 20 results from an estimated 10000 matches similar to: "eager loading has_one fix"

2008 Sep 16
3
has_one :through eager-loading problem
I have a problem with the :include option in find for my has_one :through association. I have Users, Profiles and Customers, all connected to each other with a has_one :through => :membership association like this: class Profile < ActiveRecord::Base #could also be user or customer has_one :membership # i saw an acrticle of Ryan about has_one :through, there this would be has_many, is
2010 Oct 25
1
A few fixes to eager loading issues
Hey all, I''d really appreciate some eyes on https://rails.lighthouseapp.com/projects/8994-ruby-on-rails/tickets/5845-activerecord-3-eager-loading-fail#ticket-5845-19. There''s a small issue in Rails 3 eager loading, and this ticket has an accompanying patch. Sssociations that show up twice in a Relation chain like: Article.includes(:comments).includes(:comments =>
2009 May 25
4
after_create and has_one association bug?
Hello, I''ve come across an issue that I''m sure is a bug when using after_create with a has_one association, but I''m not 100% certain if I''m missing something. This is pretty much exactly the code I''m using. Two simple classes (Account and Contact) and I create the contact after I create an account (via after_create). I''m not passing in a
2008 Nov 12
5
dynamic condition for has_one and eager loading issue
Hi, I ve defined the following relation in one of my models with a dynamic where condition: has_one :selection, :foreign_key => ''object_id'', :conditions => ''selection_type = 1 and account_id = # {self.send(:account_id)}'' That works perfect, however when I try to eager load that relation I am getting the following error when doing a
2008 Sep 02
1
Deploying Rails patches (diff)
I am having a problem with a belongs_to and a has_one :through relation which I found is a known bug in Ruby on Rails: http://rails.lighthouseapp.com/projects/8994/tickets/323-has_many-through-belongs_to_association-bug This ticket has 6 different attachments. Do I need all of them, or just the latest one? I can''t seem to find anywhere how one is supposed to deploy these patches.
2008 Apr 23
2
Bug in eager loading and polymorphic associations?
Hi friends, i''m usgin the edge version because i need eager loading on polymorphic associations support, but i see this: Message.find(:first, :include => :owner) #This generate this query: SQL (0.000072) SET SQL_AUTO_IS_NULL=0 Message Load (0.000389) SELECT * FROM `messages` User Load (0.001070) SELECT * FROM `users` WHERE (users.id IN (1,2)) And this Message.find(:first,
2009 Oct 08
6
Eager Loading a Relationship That Has No PK/FK
I''m attempting to wrestle an old DB into Rails. This relationship is giving me trouble: class Show < AR::Base has_many :segments end class Segment < AR::Base belongs_to :show has_one :media #this has no PK/FK relation end A Segment is "linked" to Media by Media.name, which is the result of concatenating Segment.name and Segment.part. As I said there are is no
2005 Jul 14
1
Single-table inheritance and eager loading
I have a people table with four types of people: clients, spouses, children, and others all setup using single-table inheritance with a foreign key back to a household record. A Household has_one client and spouse, and has_many children and others. I want to use a single "Household.find(@session [:household_id], :include => [:client, :spouse, :children, :others])"
2011 Feb 28
3
Feature: ActiveResource - Adding associations through reflections
Hello everyone, I''m new in contributing and i saw in the contributing-guides, that i have to write an email at this list. I hope, that''s the right place for this. If it''s not, i''M really sorry.. ;) Could someone please give me feedback about this lighthouse-ticket?
2005 Apr 27
5
Eager load mysteriously deletes records
Hi This looks like a bug in ActiveRecord. I am messing with eager loading (on 12.1) and all of a sudden records started disappearing from a table (and I am not doing anything delete related)!! The following line works OK:- @todos = Todo.find(:all, :include => [ :whens],:order => "position ASC") The following line is mysteriously deleteing :where rows from the DB after
2009 Mar 25
11
ActiveRecord: Nested :include erroneous behavior
Hi, Found a simple example breaking on moving to 2.2 from 2.0. This example illustrates the usage of nested :include finder options. class Book < ActiveRecord::Base has_many :distributors end class Distributor < ActiveRecord::Base belongs_to :book has_many :agents end class Agent < ActiveRecord::Base belongs_to :distributor has_many :shops end class Shop <
2007 Sep 25
2
Patch Review for selective joining of eager-loaded tables in pre-query
For those of you following the earlier saga of the performance of limited eager loading, I''ve decided to give up on pursuing my original patch. I received some support on the simplification argument (see my blog if you don''t know what I''m talking about), but it doesn''t seem like it''s worth breaking existing behavior. So I''m moving onto
2010 Jun 09
1
[patch] fix bytesize in exception template; multibyte titleize
Hi all, I wanted to draw some attention to a couple of very small multibyte-related patches I believe should be included before Rails 3.0 RC1: * Use String#bytesize rather than String#length in exception templates: This is a simple case where string length is checked, but bytes is needed, so it breaks with string with multibyte chars.
2006 May 12
1
can I fake has_one :through?
I''m having a difficult time wrapping my head around a set of models and their associations and seeing how they map into Rails. I''ll try to lay out my problem using the has_many and belongs_to structures. I have a RuleSpace, a Rule, and a Subject. A RuleSpace has_many Rules A RulesSpace has_many Subjects through Rules A Rule belongs_to (many) RuleSpaces A Rule has_many
2008 Sep 29
1
has_one :through with :source. How to alias association?
Hi to everyone, I have the following models: class Attachment < ActiveRecord::Base has_attachment :content_type => [:image, ''application/pdf''], :max_size => 3.megabytes, :path_prefix => ''../private/attachments'', :storage => :file_system, :processor => :rmagick,
2005 Aug 04
1
Pagination and :include (eager associations)
I have tried to use eager association with pagination, but the :include option is not supported: Here''s the one-line pagination call without :include @link_pages, @links = paginate :link, :per_page => 10, :order_by => sort_clause and here the work around, using the "classic" method # @link_pages = Paginator.new self, Link.count, 10,
2005 Oct 18
3
hand writing sql for eager loading of thumbnails
Can anyone point me to a resource for hand coding some sql so I can create my own for the following models: I''m using single table inheritance to store related objects eg: Thumbnail < Image < File :: ActiveRecord:Base Image has_many thumbnails Thumbnail has_one image When I come to list thumbnails I''d like to be able to: 1. List all images relating to a product 2.
2010 Apr 05
2
Harmonizing JSON/XML serialization
The way Rails handles root nodes in JSON and XML serialization is inconsistent. This has been discussed before: https://rails.lighthouseapp.com/projects/8994/tickets/2584-232-activeresource-json-doesnt-send-parameters-with-root-node This seems mostly taken care of with ActiveModel::Base.include_root_in_json, especially if/when it ends up in ActiveResource. However, there is also the issue of how
2011 Mar 30
3
Metasearch eager loading instead of lazy loading
Hey all, I have two models, in the first model Model1.search(nil) returns the metasearch builder as expected. for the the second model, the same search(nil) returns every object in the database (all 60k of them). This obviously isn''t what I want. I can''t seem to figure out what I did to the model to get it to behave this way, I have removed all of the code from the model
2010 Apr 18
1
Add shorthand support for routes like /projects/status(.:format)
Hi, when trying to migrate Signal to Rails 3 I tried to use the shorthand route for: match ''/projects/status(.:format)'' but it thrown an error because the controller was not specified. This happend because actually the shorthand routes only work with routes without optional parameters. The modification to support routes ending with a optional parameters is very simple, as can