Skip to content

Commit 28fccad

Browse files
Merge pull request rails#18984 from rousisk/master
Replace deprecated readonly option with scope blocks in docs and guide
2 parents b5ce186 + 6ef2ce0 commit 28fccad

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

Diff for: activerecord/lib/active_record/associations.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -1386,7 +1386,7 @@ def has_many(name, scope = nil, options = {}, &extension)
13861386
# has_one :last_comment, -> { order 'posted_on' }, class_name: "Comment"
13871387
# has_one :project_manager, -> { where role: 'project_manager' }, class_name: "Person"
13881388
# has_one :attachment, as: :attachable
1389-
# has_one :boss, readonly: :true
1389+
# has_one :boss, -> { readonly }
13901390
# has_one :club, through: :membership
13911391
# has_one :primary_address, -> { where primary: true }, through: :addressables, source: :addressable
13921392
# has_one :credit_card, required: true
@@ -1514,7 +1514,7 @@ def has_one(name, scope = nil, options = {})
15141514
# belongs_to :valid_coupon, ->(o) { where "discounts > ?", o.payments_count },
15151515
# class_name: "Coupon", foreign_key: "coupon_id"
15161516
# belongs_to :attachable, polymorphic: true
1517-
# belongs_to :project, readonly: true
1517+
# belongs_to :project, -> { readonly }
15181518
# belongs_to :post, counter_cache: true
15191519
# belongs_to :comment, touch: true
15201520
# belongs_to :company, touch: :employees_last_updated_at

Diff for: guides/source/association_basics.md

+2-3
Original file line numberDiff line numberDiff line change
@@ -1986,8 +1986,8 @@ While Rails uses intelligent defaults that will work well in most situations, th
19861986

19871987
```ruby
19881988
class Parts < ActiveRecord::Base
1989-
has_and_belongs_to_many :assemblies, autosave: true,
1990-
readonly: true
1989+
has_and_belongs_to_many :assemblies, -> { readonly },
1990+
autosave: true
19911991
end
19921992
```
19931993

@@ -1999,7 +1999,6 @@ The `has_and_belongs_to_many` association supports these options:
19991999
* `:foreign_key`
20002000
* `:join_table`
20012001
* `:validate`
2002-
* `:readonly`
20032002

20042003
##### `:association_foreign_key`
20052004

0 commit comments

Comments
 (0)