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: circular require considered harmful. #7650
Conversation
@@ -6,6 +6,8 @@ class Admin::User < ActiveRecord::Base | |||
store :json_data, :accessors => [ :height, :weight ], :coder => JSON | |||
store :json_data_empty, :accessors => [ :is_a_good_guy ], :coder => JSON | |||
|
|||
undef :phone_number, :phone_number= |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think is better to remove :phone_number
from the store_accessor
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In first, I removed it. But I got test failure.
1) Failure:
test_0020_all stored attributes are returned(StoreTest) [test/cases/store_test.rb:139]:
--- expected
+++ actual
@@ -1 +1 @@
-[:color, :homepage, :favorite_food, :phone_number]
+[:color, :homepage, :favorite_food]
If remove one, the following lines aren't executed.
https://github.com/rails/rails/blob/master/activerecord/lib/active_record/store.rb#L88-89
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The problem is that the warning will be showed either in the application so I don't think we should define the store_attribute
and also the custom accessor. If this test fails we can remove :phone_number
from the assertion
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with you. I'll change this.
I updated and rebased. @fxn please comment this especially 2a6f57f ? |
@kennyj I cherry picked 1f42db8. Could you update this pull request to include only 2a6f57f? |
@rafaelfranca done. |
Hi, two questions over here:
|
|
The interesting thing is that the warning is raised after the Deprecation class is defined. After following backtraces I have tracked down the issue to this (executed under activesupport):
and seem to be related to the fact that active_support.rb sets an |
BTW: In the first draft about this PR, class ActiveSupport::Deprecation; end # ★added
require 'active_support/core_ext/module/deprecation'
require 'active_support/deprecation/instance_delegator'
require 'active_support/deprecation/behaviors'
require 'active_support/deprecation/reporting'
require 'active_support/deprecation/method_wrappers'
require 'active_support/deprecation/proxy_wrappers'
require 'singleton'
module ActiveSupport
# \Deprecation specifies the API used by Rails to deprecate methods, instance
# variables, objects and constants.
class Deprecation
include Singleton |
I can't think of a better way to avoid this warning. Everything seems used just fine, problem is since we defer loading to I'll keep thinking about it, but let's merge. I'll add a comment later. |
Fix warning: circular require considered harmful.
I saw some warning when executing rails own testcases.
I don't know 8b05cfa is best way ;)
Please review it !