Dave Sims wrote:
> But the output shows no WHERE clause on the select, and in any case I 
> would
> expect that conditions like this on a belongs_to would prevent 
> persisting
> that relationship to begin with, on the INSERT not the SELECT. This 
> option
> seems to have no effect on a belongs_to association, unless I'm missing
> something. The option makes sense on a has_many, I just don't see how it
> applies to belongs_to.

Take this contrived example:

Department
  has_many :people
end

Person
  belongs_to :department, :conditions => { :name => "Development" }
end

person # assume this exists
person.department.name
=> "Development"
department # assume this exists
department.name
=> "Marketing"
person.department = department
person.save
person.reload
person.department
=> nil

SELECT * FROM "departments" WHERE ("departments"."id" = 1 AND 
("departments"."name" = 'Development'))
-- 
Posted via http://www.ruby-forum.com/.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to