Skip to content

Commit

Permalink
Fix Ruby 2.7 keyword params deprecation warning (#939)
Browse files Browse the repository at this point in the history
This fixes the following warnings that are printed when using friendly_id with Ruby 2.7.1:

Using friendly_id @ master:

```
friendly_id-984dac788d10/lib/friendly_id/history.rb:75: warning: Using the last argument as keyword parameters is deprecated; maybe ** should be added to the call
rails-370188aea03f/activerecord/lib/active_record/associations.rb:1370: warning: The called method `has_many' is defined here
```

Using this PR, no warnings are printed.
  • Loading branch information
mattbrictson authored Apr 13, 2020
1 parent 59d3de5 commit fab2b78
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/friendly_id/history.rb
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def self.setup(model_class)
# Configures the model instance to use the History add-on.
def self.included(model_class)
model_class.class_eval do
has_many :slugs, -> {order(id: :desc)}, {
has_many :slugs, -> {order(id: :desc)}, **{

This comment has been minimized.

Copy link
@marcrohloff

marcrohloff Aug 24, 2020

The double-splat plus hash is odd, I would suggest:

has_many :slugs, -> {order(id: :desc)}, 
          as:         :sluggable,
          dependent:  @friendly_id_config.dependent_value,
          class_name: Slug.to_s
:as => :sluggable,
:dependent => @friendly_id_config.dependent_value,
:class_name => Slug.to_s
Expand Down

0 comments on commit fab2b78

Please sign in to comment.