Displaying 2 results from an estimated 2 matches for "published_posts".
2006 Jan 31
4
Rails bug? Conditions on associations ignored by eager loading
...le "posts", :force => true do |t|
t.column "blog_id", :integer
t.column "subject", :string
t.column "published", :boolean
end
The model for blogs looks like this:
class Blog < ActiveRecord::Base
has_many :posts
has_many :published_posts, :class_name => ''Post'', :foreign_key
=> ''blog_id'', :conditions => ''published = 1''
end
Now add some sample data for blogs:
example:
id: 1
name: Example
and for posts:
published:
id: 1
blog_id: 1
su...
2007 Jan 17
4
changing the default behaviour of to_xml for has-many: associations
I recently submitted a patch to work around an issue I was having &
added a new optional behaviour to the to_xml method but on further
reflection I wonder if the default behaviour should be changed.
The gory detail, documentation and test case is all here...
http://dev.rubyonrails.org/ticket/7004
Here''s a brief example...
class Person < ActiveRecord::Base
has_many: children