Displaying 20 results from an estimated 200 matches similar to: "Eager Loading + Confusion"
2006 May 16
1
:conditions on has_one realationship
Hi there,
I''m currently building a membership application and I want to be able
to select, not just all the memberships, but the most current
membership from the database on a per user basis. I have linked the
tables as shown:-
class Membership < ActiveRecord::Base
belongs_to :payment
belongs_to :person
end
class Person < ActiveRecord::Base
has_many :memberships
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
2006 Jun 25
2
how to write the codes in view?(newbie question)
Hi.
I have two tables and want to join them.
<genres>
id
genre_name
genre_order
<links>
id
genre_id
name
symbol
url
order
display
etc
The code of links_Controller is like below.
def list
@links = Genre.find(:all,:include => :link)
end
Below is the mysql log.
SELECT genres.`id` AS t0_r0, genres.`genre_n
ame` AS t0_r1, genres.`genre_order` AS t0_r2, links.`id` AS t1_r0,
2006 Jan 09
3
Include with two references of one model of the same table
Hey guys,
I just came across this oddity, not sure what to make of it yet, but
I think it might be incorrect behavior. When doing a @inst.find(:all,
:include => ["hometeam", "awayteam"] ...) hometeam and awayteam are two
references from a belongs_to that is of the same model and of the same
table. I will get a pgerror stating that "matches", which is
2007 Dec 12
2
possible bug in eager loading
Hello,
@users = User.find(:all, :include => {:user_data =>
:user_data_field}, :order => "username = ''someone-oHC15RC7JGTNLxjTenLetw@public.gmane.org'' desc",
:limit => 50)
This produces:
User Load IDs For Limited Eager Loading (74.648762) SELECT * FROM
(SELECT DISTINCT ON (users.id) users.id, username AS alias_0 FROM users
LEFT OUTER JOIN
2006 May 23
5
AR Caching and Reflection
When I do this:
term = Term.find(1, :include => :definition)
term.definition.term
Two SQL queries are fired, why?
--
Posted via http://www.ruby-forum.com/.
2012 Aug 31
3
Feature Request: Auto-infer .includes from .where with ActiveRecord queries
In the following snippet, can''t the includes being inferred from the where
clause?
Order.includes(:items).where(:items => { :category => [1,2,3] })
Can''t the includes be inferred from the where clause?
Order.where(:items => { :category => [1,2,3] })
Would this conflict with any existing usages of the where clause and
hashes?
--
You received this
2006 May 20
3
In a find, can''t you use both :include and :limit ?
I''m trying to do a find that includes a join. It has to be a find
because I''m using the results for a Pagination, so I need to limit my
query to the number of results I want to display per page.
Here''s the type of thing I want to do:
Employee table <-> Skills_Employees table <-> Skills table
Let''s say I want to find all the employees who have
2009 Feb 22
2
Mysql error unknown column 'columns.user_id'
Had this error when trying to add comments to another user''s photo.
ActiveRecord::StatementInvalid in User photosController#show
Mysql::Error: Unknown column ''comments.user_id'' in ''on clause'': SELECT
photos.`id` AS t0_r0, photos.`user_id` AS t0_r1, photos.`title` AS
t0_r2, photos.`body` AS t0_r3, photos.`created_at` AS t0....
I did create a user_id
2007 May 22
2
find :all :include broken on Oracle 10
Hi,
I am trying the following in Ruby using InstantRails 1.7 on WindowsXP
Publication.find(:all, :include => [:doc_type, :release_state] )
but I get the error:
OCIError: ORA-00904: "DOC_TYPES"."PUBLICATION_ID": invalid identifier:
SELECT publications.id AS t0_r0, publications.docid AS t0_r1,
publications.doc_type_id AS t0_r2, publications.title AS t0_r3,
2009 Jan 04
3
Table associated problem using belongs_to
I have two tables:
Table [packages]
id name user_name
-------------------
1 PK1 Ray
-------------------
Table [users]
id name full_name
-------------------
2 Ray Ray Sun
-------------------
My purpose is to find the full name when I find packages. So I modify
Model Package to:
class Package < ActiveRecord::Base
belongs_to :user,
:class_name => "User",
2006 Apr 19
2
I need help in ActiveRecord..
I have this Product.find(:all, :include => [:brand, :category, :type],
:group =>
"description"), but it dont group by description why?
Bruno
--
Posted via http://www.ruby-forum.com/.
2006 Feb 22
5
Optional Include Relationship
I did some searches in the mailing list and on the web but I can''t
seem to find the answer to this, but it''s pretty much a noob question.
I have a Product object
class Product < ActiveRecord::Base
has_many :product_identifications
has_one :product_identification_item_number
has_one :product_identification_product_code
end
the product_identifications is using
2006 Sep 01
3
find_by_sql with :include?
When you use find, you can include related objects with include so that
both objects get instantiated in the results, e.g. Foo.find(:all,
:include => :bar).
But when you use find_by_sql, is there a way to do this? You could
definitely write the find_by_sql SQL to join Foo and Bar tables:
Foo.find_by_sql("SELECT foo.*, bar.* from foo, bar where foo.bar_id =
bar.id")
But is there a
2005 Dec 29
1
Resolving ambiguous columns during a join
I am working with an existing schema and thus limited in how much I can
bend my existing column names. I have a table Users, and a table
ForumUsers, for which I have a "has_one" relationship - a user has_one
forumuser. When I look at my user records I wish to include some
information from forumuser:
@users = User.find :all, :include => :forum_user, :order =>
2006 Jan 10
1
sql server & linux: left join problem
I''ve got a left join problem of some sort connecting from linux
FreeTDS/ODBC to SQL Server. It''s similar to the false post I had
earlier, but this is a real problem. Here''s my code:
def find_recipes_for_workorder
@recipe_pages, @recipes = paginate_with_sort :recipes, :per_page
=> 10, \
:joins => ''left join workorder on
2006 Apr 06
7
[Fwd: Rails AR/Oracle Unit Test: [4185] failed]
So my automated script caught this issue, though I think my email
headers were bad, so rails-core has put the automated email on hold
pending "moderation".
I''ll fix that issue, and look at the one below as well.
-------- Original Message --------
Subject: Rails AR/Oracle Unit Test: [4185] failed
Date: Thu, 6 Apr 2006 08:32:04 -0700
From: Michael Schoen
2006 Jul 24
7
[PATCH] Support for DB Clusters/Replication in ActiveRecord (RFC)
Skipped content of type multipart/alternative-------------- next part --------------
Index: connection_adapters/abstract/connection_specification.rb
===================================================================
--- connection_adapters/abstract/connection_specification.rb (revision 4617)
+++ connection_adapters/abstract/connection_specification.rb (working copy)
@@ -1,10 +1,21 @@
require
2006 Jul 02
18
JOIN conditions
Hi,
how can I get Rails to generate SQL queries with conditions in the JOIN clause?
What I would want is:
SELECT * FROM people p
LEFT OUTER JOIN jobs j (p.job_id = j.id AND j.salary > 9999999)
I tried
People.find(:all, :include => ''jobs'', :conditions => ''jobs.salary > 9999999'')
but that generates
SELECT * FROM people p
LEFT OUTER
2006 Jan 10
1
sql server freetds/odbc question
I''m having an error from Linux via freeTDS/ODBC to SQL Server with
cod that runs fine against SQLite and MySQL. Here''s the code:
def find_recipes_for_workorder_by_id
@recipe_pages, @recipes = paginate_with_sort :recipes, :per_page
=> 10, \
:conditions => ["recipe.workorder_id = ?", params
[:workorder]]
render :template =>