similar to: Feature Request: Auto-infer .includes from .where with ActiveRecord queries

Displaying 20 results from an estimated 4000 matches similar to: "Feature Request: Auto-infer .includes from .where with ActiveRecord queries"

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
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/.
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 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
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 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 Jul 04
13
NewBie question
Hi, I m very new to Ruby. I bought a book "Ruby on Rails" and I think I understand some concepts. My question is : Is there a way to not use "Cookies" or "Sessions Variables" to keep some information about the user. I ask this question because I would like to prevent some cases where the user browser won''t accept cookies. I m from Asp 3.0, and I
2008 Mar 28
6
Eager Loading + Confusion
So I''m trying to do a find with an order by specific column values thing, but some of the columns are attributes through associations. So I did some eager loading with the :include option to try and access the attributes of the object I''m doing the find on. Stuff has been blowing up on me so far. Here''s the code in the controller right now: sort_by = params[:sort_by]
2008 Feb 09
0
MVC interplay to query multiple models
I''m trying to track down why I''m getting close to desired output, but not quite. It looks like the webpage sorta-kinda is grabbing the right data. For instance, there are three Login objects which should be showing and it looks like the show is grabbing three objects, so that fits, to a degree. However, it''s just grabbing the hexadecimal object id, and not
2006 Mar 15
8
Tags to ruby interface: What I am missing? (repost)
I offer my apologies in advance for the repost. On a list as busy as this, it is sometimes easy to get missed in the shuffle. I am trying to create, display and edit a referenced object''s text field on the same view as my root object. For example: ------------------------- Quiz: <<quiz.name>> Preamble: <<quiz.preamble_presentation.text>> Postamble:
2013 Oct 08
4
'puppet storeconfigs export' killed
Hi, I currently have a MySQL database containing all Puppet storeconfigs. My intention is to migrate to PuppetDB on a PostgreSQL server, so the first step is to use the ''storeconfigs'' face to export all the DB to a file PuppetDB can later consume. But the ''puppet storeconfigs export'' command always ends up being killed, I suspect due to some sort of OOM
2009 Mar 10
5
'unknow column error' when using include and associated table condition in find
Here is my weird problem. Two models like following: Lexeme id:int name:string Structure id:int ref_id:string meta_id:int Lexeme can have many structure records through foreign key ''ref_id'' in the structures table. And these structure records belonging to one lexeme differs between each other using meta_id. And if Lexeme has structures, then there must be a top_struct whose