Displaying 20 results from an estimated 10000 matches similar to: ":include with conditions."
2007 Jul 26
1
Bi-directional self-referential HABTM
Hi,
I''m having a little trouble figuring out how to make a self-
referential HABTM bi-directional.
I have a Employee class. Each employee can have a couple of bosses,
who are also employees. The employee class has the following HABTM:
has_and_belongs_to_many :bosses, :class_name =>
"Employee", :join_table => "bosses_courses", :association_foreign_key
=>
2006 May 11
1
ActiveRecord collection_select and has_and_belongs_to_many
Hello everyone, first post to the list and a relative newbie to Rails
development. Done quite a bit of JSP, PHP, HTML, XML etc and thought I would
kick the tires on Rails to see if it can speed up development for internal
applications. Anyway, I am running into a problem that is just driving me
crazy and everything I read on the net doesn''t seem to help. I was hoping
someone here might
2006 Aug 02
2
Self-Referential has_many :through
Hello all.
I am trying to create a self-referential has_many :through. I used the
following site as a guide
http://blog.hasmanythrough.com/articles/2006/04/21/self-referential-through
but it still doesn''t appear to be working. I have two models. Person and
Relationship. A person has many contacts (Which is another person)
through relationships
class Person < ActiveRecord::Base
2006 Jun 18
10
acts_as_enumerated
Hello All,
Any one using acts_as_enumerated? I need help using (I like that it
caches values in memory)
I am working on a dating website and there are lots of options I want to
store as enumerated like
Status; divorce, single,
Sex: male, female
Eye color; blue, brown, green....
and lots more....
But I do not wanna keep them in seperate tables, and wanna keep them all
together.
Anyone has a
2006 Jan 31
4
Rails bug? Conditions on associations ignored by eager loading
I''m looking for someone to confirm the following as a bug in Rails
1.0 before I post it to Trac.
If I use eager loading on an association that has conditions defined,
the conditions are ignored.
The following example illustrates the problem. I have two tables:
create_table "blogs", :force => true do |t|
t.column "name", :string
end
create_table
2007 May 20
1
beating a dead horse - proper association selection
okay... i have two models
employee
- id
- username
order
- id
- number
- created_by
- approved_by
now created_by and approved_by are both id''s of employees. in most
cases, two different employees.
currently i do something like
//controller
@open_orders = Order.open_orders
//model
def self.open_orders
find(:all, :conditions => [''is_open = ?'', true],
2006 Sep 03
1
New Technique: Subsets of has_many Associations
I just now thought of this, and sure enough it works like a charm (at
least so far in my limited testing):
has_many :events, :dependent => :delete_all
has_many :upcoming_events, :class_name => "Event", :conditions =>
"date > NOW()"
The purpose of this is that it makes eager loading of subsets of
associations possible without replacing all the magic of the
2006 Feb 09
2
Crazy @55 Inheritance
I have one table, called "people".
Within this table, there are type "users", "managers".... etc. So, basic
STI.
Now, I want a "user" to have one manager, but a "manager" to have many
"users".
Since I don''t want to use HABTM... how do I set this relationship up seeing
that :has_one, :belongs_to and :has_many don''t
2010 Aug 05
3
how to ? Rails 3 ActiveRecord eager loading and AREL
Hello everyone,
I would like to eager load scoped records to avoid queries executed in a
loop (huge performance impact).
The "scoped" part is what is giving me a hard time.
I''m using Rails3 RC.
Does anyone have any idea how I can do it?
Here is a test case : we have an "Article" and a "Comment" Activerecord
models,
article has many comments
comment
2006 Mar 31
3
Complex Through Statement
Quick Overview:
I have an ''Employee'', some ''Merchants'' and some ''Products''. A
''Merchant'' has many ''Products''. An ''Employee'' has multiple ''Merchants'',
depending on their relationship. For example, the Employee may be the
enrollment contact for one merchant and the
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
2007 Jan 03
3
Self-referential habtm with condition is broken
Here''s a simplistic model class.
class Person < ActiveRecord::Base
has_and_belongs_to_many :relatives,
:class_name => ''Person'', :join_table => ''relatives'',
:foreign_key => ''from_id'', :association_foreign_key => ''to_id''
has_and_belongs_to_many :brothers,
:class_name =>
2006 Aug 04
2
problem eager loading with sti
Here''s the setup (working off Rails 1.1.4):
Class Project
belongs_to :employee
Class Employee < Person
has_many :projects
When I try to paginate(:employees, :include =>
:projects) I get the error "Association named
''projects'' was not found; perhaps you misspelled it?"
I can :include other models that the Person class
has_many or habtm of, and if I
2005 Jul 08
1
DSL Provider
First of all sorry for the little offtopic post :-)
For one of our customers i need to make a vpn between the Netherlands
and Hungary.
Over this vpn two * machines are gonna talk IAX and employees in Hungary
are gonna use the Exchange server located in the Netherlands.
So far no problem...
The problem: I'm from in the Netherlands and don't understand the .hu
websites :-(
First question:
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
2006 Mar 01
1
Eager loading problem. Help greately appreciated
Each Timesheet has an employee. An employee has a division and a
location.
I want to find all the timesheets with a status of 2. I then iterate
over the timesheet collection and print the timesheet name, employee
name, employee divison name, and employee location name. Like so:
for t in
Timesheet.find(:all,:conditions=>"status=2",:include=>:employee)
puts timesheet.date
2008 Dec 13
3
how to do "special queries" ala The Rails Way on "associated" conditions?
I have the following in a model class:
class Game < ActiveRecord::Base
has_many :player_stats
has_many :players, :through => :player_stats
def visitor_stats
stats = []
player_stats.each do |stat|
stats << stat if stat.player.team.team_code ==
self.visiting_team_code
end
stats
end
def home_stats
stats = []
player_stats.each do |stat|
stats << stat if
2006 Jan 19
0
Limited eager loads and conditions on the eager tables
Hi,
Why are limited eager loads and conditions on the eager tables incompatible?
Doing a find(:all) without :include causes a select * query to be generated,
which means the id fields everwrite each other if associated tables are
included using :joins.
But using :include, if conditions are placed on the tables listed in :joins
then Rails throws an exception when :limit is included too.
2007 Jul 12
4
file couldn't play after Speex encode and decode
Dear sir,
I've a problem that the .wav file couldn't play after calling "sampleenc
male.wav|sampledec male_speex_15.wav".I found that the new file
male_speex_15.wav is smaller than the original file in size.I implemented
the test on Linux system.The original file male.wav is 96044 bytes,while the
new file male_speex_15.wav is 96000 bytes.I'm eager to know the reason.Thankyou!
2006 Apr 03
2
Problems with STI in has_many/belongs_to in Rails 1.1
I have a problem that surfaced in my attempt to upgrade my application
to Rails 1.1.
We have a STI model on the "belongs_to" side of a has_many/belongs_to
relationship. All my unit tests for this model pass, and the
relationships all seem to work fine.
But in my functional tests, I''m getting errors. I''ve traced it back
into the call to the has_many