Comments (8)
Fixed in 9c80976
from acts-as-taggable-on.
Problem is not solved.
Code:
Post.create! :tag_list = "one, two"
post = Post.first
post.save!
post = Post.first
post.tag_list # => []
post.cached_tag_list # => "
post.tags # => [#<Tag id: 5, name: "one">, #<Tag id: 6, name: "thow">]
from acts-as-taggable-on.
I confirm. Problem is not solved. Critical.
from acts-as-taggable-on.
Hi! I confirm. Problem isn't solved and remains critical.
About what dsmalko said:
- post.tag_list is empty after save! because it (just) load tags from cached_tag_list if caching is enabled
- cached_tag_list is empty because save_cached_tag_list sets it to an empty string on save! because tag_list_cache_on returns nothing (@my_custom_tag_list is not initialized - look at tag_list_cache_on)
This bug is critical. Not only cache is not reliable but also we loose taggings if fields about our tags are filled with my_custom_tag_list method (it's empty due to cached and so... bye bye baby on form submit - argh!).
Today i spend one hour to figure out what was happening.
This is my patch. It seems to work well
/lib/acts_as_taggable_on/acts_as_taggable_on.rb @387
remove:
send(:"cached_#{tag_type.singularize}list=", tag_list_cache_on(tag_type.singularize).to_a.flatten.compact.join(', '))
use:
list = tag_list_cache_on(tag_type.singularize)
send(:"cached#{tag_type.singularize}_list=", list.to_a.flatten.compact.join(', ')) if list.any?
My patch takes hash from tag_list_cache_on and check if it's empty. Only if it's not empty I update cache column. If tag_list_cache_on returns {} I assume that @my_custom_tag_list is not initialized, so there is no change about tags and no need to update cache column (this avoid to save empty cache columns when @my_custom_tag_list is not initialized).
Anyway I can't be completely sure about what I assume at the moment, but I think that hash cannot be empty, just because it's a pair of owner => tags and if there is no owner for a tag (or not tags at all) we always have at least a nil key, for example {nil => []}. Isn't it?
I'm testing. For the moment my patch works well.
I'm sorry for my bad english! :)
from acts-as-taggable-on.
Also If you don't want to patch your plugin or wait a fix, just call your_custom_tag_list method before save so instance variable will be initialized
from acts-as-taggable-on.
Testing and one week on production. Patch is ok.
from acts-as-taggable-on.
I've fixed this problem in version 2.0.0 which was just released
from acts-as-taggable-on.
ty!
from acts-as-taggable-on.
Related Issues (20)
- getting some NameError exceptions when my Rails app is first started up HOT 1
- Tag queries are performed even though I'm not calling / using the tags HOT 2
- Improving Performance of Tags HOT 4
- Install / migration error on Rails 7.0.2.2 HOT 5
- Several redundant indexes are possibly created by the default migration files generated HOT 1
- `:any => true` performance issue HOT 1
- How to get a list of all tags, but only for one context? HOT 2
- Getting "uninitialized constant ActsAsTaggableOn::Taggable::TagListType"
- ActiveRecord::UnknownAttributeReference - Dangerous query method HOT 1
- Support for labels through additional columns in tags table?
- Question: Validations of tag length
- ActiveModel::UnknownAttributeError with upsert
- No implicit conversion of nil into String error.
- Ownership does not work with tenancy HOT 1
- How to use cache appropriately? HOT 1
- Still actively maintained? HOT 1
- Support with multiple taggable objects HOT 1
- Errors when trying to execute .count in the result of .tagged_with
- rails 7.1 gemspec issue HOT 3
- Issue on Rails 7.1 upgrade HOT 9
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from acts-as-taggable-on.