4 ms·
Ruby methods can have both positional and keyword arguments, so, in this case, the `has_many` method takes the symbol `:players` as an argument and takes a keyw
by chris12321 2y ago
Ruby methods can have both positional and keyword arguments, so, in this case, the `has_many` method takes the symbol `:players` as an argument and takes a keyword argument called `dependent:` which is being passed the symbol `:destroy_async`. Where a symbol in Ruby is an immutable identifier.
So a method like this would be defined as something like:
def has_many(model_name, dependent:)
puts model_name.to_s
puts dependent.to_s
end
Which you could then call as:
has_many(:players, dependent: :destroy_async)
or
has_many :players, dependent: :destroy_async
Since you don't need to put parenthesis around method arguments in ruby.