Displaying 2 results from an estimated 2 matches for "university_id".
2005 Mar 08
19
find_by_sql ON STEROID possible?
....*,
p.*,
a.*,
u.*
FROM books b,
publishers p,
authors a,
authors_books ab,
universities u
WHERE b.publisher_id = p.id and
a.id = ab.author_id and
b.id = ab.book_id and
a.university_id = u.id
that fetch every association in the (publisher book author university) db model
active record is based on NAMING CONVENTIONS so why can''t we do that?
(no matter if it''s fastidious because it''s optimization time of the dev process
!!!!!!)
Books.find_by_sql(
&q...
2006 Aug 16
1
using :select with :include to limit eager loading
...'' does not appear to work when
:include is used to eager load associations. However, I sometimes want
to perform ready-made joins on associations to limit the results of a
query. here''s a simple example:
table university:
STRING code
INT id
table term:
STRING name
INT university_id
INT id
the associations of the models
University
has_many :terms
Term
belongs_to :university
if I want to select the terms with a given university, I can perform the
straightforward function:
Term.find(:all, :include => :university, :conditions => "university.code
= ''s...