Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix warning: method redefined; #29963

Merged
merged 1 commit into from
Jul 30, 2017
Merged

Conversation

y-yagi
Copy link
Member

@y-yagi y-yagi commented Jul 26, 2017

This fixes the following warning:

/tmp/d20170727-7039-kmdtb1/app/app/models/user.rb:5: warning: method redefined; discarding old model_name
rails/activemodel/lib/active_model/naming.rb:222: warning: previous definition of model_name was here

@rails-bot
Copy link

r? @pixeltrix

(@rails-bot has picked a reviewer for you, use r? to override)

Copy link

@lugray lugray left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@rafaelfranca
Copy link
Member

Instead of removing the instance method can we override the class method that is exactly what Naming implements?

@y-yagi
Copy link
Member Author

y-yagi commented Jul 27, 2017

Instead of removing the instance method can we override the class method that is exactly what Naming implements?

I tried. However, it seems that the method of Naming did not use anythinge. Therefore I removed Naming extend.

@rafaelfranca
Copy link
Member

If model_name is being used, it should do something. Naming defines a model_name at class level and a model_name at instance level that delegates to the class level, so in theory we could override model_name on the class level and keep Naming to remove the warning, or, if Naming is not needed anymore model_name should not be either.

@rafaelfranca
Copy link
Member

I just tried to define the class method and it seems to work and the warning is not there anymore.

This fixes the following warning:

```
/tmp/d20170727-7039-kmdtb1/app/app/models/user.rb:5: warning: method redefined; discarding old model_name
rails/activemodel/lib/active_model/naming.rb:222: warning: previous definition of model_name was here
```
@y-yagi
Copy link
Member Author

y-yagi commented Jul 28, 2017

Thank you for the detailed explanation. I was misunderstanding.
I defines a model_name at class level.

@kaspth kaspth merged commit a78e591 into rails:master Jul 30, 2017
@y-yagi y-yagi deleted the fix_ruby_warnings branch July 30, 2017 20:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants