Froze rails gems
[depot.git] / vendor / rails / activerecord / lib / active_record / associations / has_one_through_association.rb
1 module ActiveRecord
2 module Associations
3 class HasOneThroughAssociation < HasManyThroughAssociation
4
5 def create_through_record(new_value) #nodoc:
6 klass = @reflection.through_reflection.klass
7
8 current_object = @owner.send(@reflection.through_reflection.name)
9
10 if current_object
11 current_object.update_attributes(construct_join_attributes(new_value))
12 else
13 @owner.send(@reflection.through_reflection.name, klass.send(:create, construct_join_attributes(new_value)))
14 end
15 end
16
17 private
18 def find(*args)
19 super(args.merge(:limit => 1))
20 end
21
22 def find_target
23 super.first
24 end
25
26 def reset_target!
27 @target = nil
28 end
29 end
30 end
31 end