Created
August 26, 2011 15:26
-
-
Save tekin/1173659 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class User < ActiveRecord::Base | |
has_many :events, :extend => AssociationDefaultAttributes do | |
def default_attributes | |
{ :venue => proxy_owner.default_venue } | |
end | |
end | |
end | |
module AssociationDefaultAttributes | |
def create(attrs, &block) | |
super(default_attributes.merge(attrs), &block) | |
end | |
def build(attrs={}, &block) | |
super(default_attributes.merge(attrs), &block) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment