Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: 7cba6a3784
Fetching contributors…

Cannot retrieve contributors at this time

33 lines (25 sloc) 0.824 kb
module ActiveRecord::Associations::Builder
class SingularAssociation < Association #:nodoc:
self.valid_options += [:remote, :dependent, :counter_cache, :primary_key, :inverse_of]
def constructable?
true
end
def define_accessors
super
define_constructors if constructable?
end
private
def define_constructors
name = self.name
mixin.send(:define_method, "build_#{name}") do |*params, &block|
association(name).build(*params, &block)
end
mixin.send(:define_method, "create_#{name}") do |*params, &block|
association(name).create(*params, &block)
end
mixin.send(:define_method, "create_#{name}!") do |*params, &block|
association(name).create!(*params, &block)
end
end
end
end
Jump to Line
Something went wrong with that request. Please try again.