Skip to content

Commit

Permalink
merge_with_conditions is not necessary because the conditions will al…
Browse files Browse the repository at this point in the history
…ready be in the scope_for_create hash in the scope
  • Loading branch information
jonleighton authored and tenderlove committed Jan 7, 2011
1 parent 45d0d18 commit 5ecf692
Showing 1 changed file with 0 additions and 9 deletions.
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -4,21 +4,18 @@ module Associations
class HasOneAssociation < AssociationProxy #:nodoc: class HasOneAssociation < AssociationProxy #:nodoc:
def create(attrs = {}) def create(attrs = {})
new_record do |reflection| new_record do |reflection|
attrs = merge_with_conditions(attrs)
reflection.create_association(attrs) reflection.create_association(attrs)
end end
end end


def create!(attrs = {}) def create!(attrs = {})
new_record do |reflection| new_record do |reflection|
attrs = merge_with_conditions(attrs)
reflection.create_association!(attrs) reflection.create_association!(attrs)
end end
end end


def build(attrs = {}) def build(attrs = {})
new_record do |reflection| new_record do |reflection|
attrs = merge_with_conditions(attrs)
reflection.build_association(attrs) reflection.build_association(attrs)
end end
end end
Expand Down Expand Up @@ -77,12 +74,6 @@ def new_record
replace(record, true) replace(record, true)
record record
end end

def merge_with_conditions(attrs={})
attrs ||= {}
attrs.update(@reflection.options[:conditions]) if @reflection.options[:conditions].is_a?(Hash)
attrs
end
end end
end end
end end

0 comments on commit 5ecf692

Please sign in to comment.