diff options
author | Rick Olson <technoweenie@gmail.com> | 2006-04-25 05:49:14 +0000 |
---|---|---|
committer | Rick Olson <technoweenie@gmail.com> | 2006-04-25 05:49:14 +0000 |
commit | c61b10b62be9f57dd847242471b4a30da81f16d4 (patch) | |
tree | 3e355664201bbd0ec56d61e108763886399289d3 /activerecord/lib/active_record/associations | |
parent | 4251662c1a4dbec8c69d4ab1b677950a0b4cfb58 (diff) | |
download | rails-c61b10b62be9f57dd847242471b4a30da81f16d4.tar.gz rails-c61b10b62be9f57dd847242471b4a30da81f16d4.tar.bz2 rails-c61b10b62be9f57dd847242471b4a30da81f16d4.zip |
Raise error when trying to add to a has_many :through association. Use the Join Model instead. [Rick]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@4265 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord/lib/active_record/associations')
-rw-r--r-- | activerecord/lib/active_record/associations/has_many_through_association.rb | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/associations/has_many_through_association.rb b/activerecord/lib/active_record/associations/has_many_through_association.rb index 44054b42e1..8cafb26d44 100644 --- a/activerecord/lib/active_record/associations/has_many_through_association.rb +++ b/activerecord/lib/active_record/associations/has_many_through_association.rb @@ -8,7 +8,6 @@ module ActiveRecord construct_sql end - def find(*args) options = Base.send(:extract_options_from_args!, args) @@ -41,6 +40,14 @@ module ActiveRecord @loaded = false end + def <<(*args) + raise ActiveRecord::ReadOnlyAssociation, @reflection + end + + [:push, :concat, :create, :build].each do |method| + alias_method method, :<< + end + protected def method_missing(method, *args, &block) if @target.respond_to?(method) || (!@reflection.klass.respond_to?(method) && Class.respond_to?(method)) |