diff options
author | Jeremy Kemper <jeremy@bitsweat.net> | 2008-02-13 06:32:50 +0000 |
---|---|---|
committer | Jeremy Kemper <jeremy@bitsweat.net> | 2008-02-13 06:32:50 +0000 |
commit | dfa786631bb8476c8cae555ad8de5e83811dfe9d (patch) | |
tree | f1e9a04a9966a91ac4a283e9453134cbb95755de /activerecord/test/models/company.rb | |
parent | 08a4c9979da44654f057494dc76498ed6a8506bc (diff) | |
download | rails-dfa786631bb8476c8cae555ad8de5e83811dfe9d.tar.gz rails-dfa786631bb8476c8cae555ad8de5e83811dfe9d.tar.bz2 rails-dfa786631bb8476c8cae555ad8de5e83811dfe9d.zip |
Introduce the :readonly option to all associations. Records from the association cannot be saved. Closes #11084.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8864 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord/test/models/company.rb')
-rwxr-xr-x | activerecord/test/models/company.rb | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/activerecord/test/models/company.rb b/activerecord/test/models/company.rb index c33f188a02..3d76dfd398 100755 --- a/activerecord/test/models/company.rb +++ b/activerecord/test/models/company.rb @@ -40,8 +40,10 @@ class Firm < Company :counter_sql => 'SELECT COUNT(*) FROM companies WHERE client_of = 1000' has_many :clients_using_finder_sql, :class_name => "Client", :finder_sql => 'SELECT * FROM companies WHERE 1=1' has_many :plain_clients, :class_name => 'Client' + has_many :readonly_clients, :class_name => 'Client', :readonly => true has_one :account, :foreign_key => "firm_id", :dependent => :destroy + has_one :readonly_account, :foreign_key => "firm_id", :class_name => "Account", :readonly => true end class DependentFirm < Company @@ -60,6 +62,7 @@ class Client < Company belongs_to :firm_with_basic_id, :class_name => "Firm", :foreign_key => "firm_id" belongs_to :firm_with_other_name, :class_name => "Firm", :foreign_key => "client_of" belongs_to :firm_with_condition, :class_name => "Firm", :foreign_key => "client_of", :conditions => ["1 = ?", 1] + belongs_to :readonly_firm, :class_name => "Firm", :foreign_key => "firm_id", :readonly => true # Record destruction so we can test whether firm.clients.clear has # is calling client.destroy, deleting from the database, or setting |