belongs_to with optional parameter

parent d95f5d14
......@@ -191,8 +191,17 @@ Don't mix the Ruby 1.9 hash syntax with hash rockets in the same hash literal. W
{ a: 1, b: 2 }
```
https://github.com/rubocop-hq/ruby-style-guide#hash-literals = ruby19_no_mixed_keys
---
##### `belongs_to` are not optional by default
Always specify `optional: true` when defining belongs_to associations which are not required.
```ruby
class Issue < ApplicationRecord
belongs_to :assigned_to, optional: true
end
```
## https://github.com/rubocop-hq/ruby-style-guide#hash-literals = ruby19_no_mixed_keys
#### In other cases follow community guidelines
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment