-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
[#432][#403][#433][#422] Fix checking for column cache until db connects #438
Conversation
… column cache until db connects Specifically see, mbleigh#432 (comment)
@seuros @aaronchi @shekibobo @joelcogen @dstosik can you confirm this PR fixes the issue for you? |
It seem the the issue is resolved. 👍 Thank you! |
end | ||
|
||
def acts_as_taggable_on(*args) | ||
super(*args) | ||
initialize_acts_as_taggable_on_cache |
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.
Hmm, looks like we're calling this method twice.. but that's existing behavior
@seuros Thanks, since I was only able to duplicate it console, and need to think about how to test. |
# we do the caching column check and dynamically add the class and instance methods | ||
def columns | ||
@acts_as_taggable_on_columns ||= begin | ||
db_columns = super |
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 check for table_exists?
should not be necessary here
[mbleigh#432][mbleigh#403][mbleigh#433][mbleigh#422] Fix checking for column cache until db connects
Fix related to #432, #403, #433, #422
Summary: When ActsAsTaggableOn::Taggable::Cache is included, it conditionally adds tag caching methods when the model has any
"cached_#{tag_type}_list"
columnDetails: ActiveRecord::Base.columns makes a database connection and caches the calculated
columns hash for the record as
@columns
. Since we don't want to add cachingmethods until we confirm the presence of a caching column, and we don't
want to force opening a database connection when the class is loaded,
here we intercept and cache the call to :columns as
@acts_as_taggable_on_columns
to mimic the underlying behavior. While processing this first call to columns,
we do the caching column check and dynamically add the class and instance methods
Also see
#432 (comment)
Very simplified description of error condition in console