Comments (11)
It just noticed that it is recording the version number and modifier in the current record, just no associated tracker.
from mongoid-history.
Did it stop working with the mongoid upgrade? I would get the code for mongoid-history, update the mongoid reference and try to run all tests first, see if anything fails.
from mongoid-history.
I'm not sure if it was the mongoid update or not, it doesn't seem likely, I didn't notice it wasn't recording new versions for several days. So it could be anything. All of my tests pass and it works 100% on my development machine.
I cloned mongoid-history and upped the gem file for mongoid from 3.0.4 to 3.0.13. 85 examples, 0 failures.
I downloaded the mongo db from the server, to be sure everything was the same, the same result. It just stopped working in production. No idea why or how to resolve it.
from mongoid-history.
Try running your app with RAILS_ENV=production locally or something like that for a repro. Then, look at how the versioning is implemented, maybe it will give you a clue.
from mongoid-history.
Running it in production on my local machine also works fine. It must be something specific with either heroku or mongohq, but I can't imagine what that could be, how it could have occurred or how to debug it further. ;-(
from mongoid-history.
Open a heroku console and get a small repro.
Enable logging with
Moped.logger = Logger.new(STDOUT)
Moped.logger.level = Logger::DEBUG
Redo the repro, capture database queries.
from mongoid-history.
Here's what I see when I do that.
Create it...
c=Article.create!(:title => "This is a title", :excerpt => "This is a brief desc.", :content => "here's some content", :user_id => User.first.id)
MOPED: 10.254.66.79:27082 QUERY database=app3383995 collection=users selector={"$query"=>{}, "$orderby"=>{:_id=>1}} flags=[:slave_ok] limit=-1 skip=0 fields=nil (1.4637ms)
MOPED: 10.254.66.79:27082 QUERY database=app3383995 collection=articles selector={"_slugs"=>{"$all"=>[/^this\-is\-a\-title(?:-(\d+))?$/]}, "_id"=>{"$ne"=>"50ad38d2ebda22048b000006"}} flags=[:slave_ok] limit=0 skip=0 fields=nil (1.4756ms)
MOPED: 10.254.66.79:27082 INSERT database=app3383995 collection=history_trackers documents=[{"_id"=>"50ad38d2ebda22048b000007", "association_chain"=>[{"name"=>"Article", "id"=>"50ad38d2ebda22048b000006"}], "scope"=>"article", "original"=>{}, "modified"=>{"state"=>"draft", "_slugs"=>["this-is-a-title-1"], "city_ids"=>[], "title"=>"This is a title", "excerpt"=>"This is a brief desc.", "content"=>"here's some content", "user_id"=>"4f69a0dfb0ac200001000001"}, "version"=>1, "action"=>"create", "updated_at"=>2012-11-21 20:25:54 UTC, "created_at"=>2012-11-21 20:25:54 UTC}] flags=[] (0.1450ms)
MOPED: 10.254.66.79:27082 INSERT database=app3383995 collection=articles documents=[{"state"=>"draft", "_id"=>"50ad38d2ebda22048b000006", "_slugs"=>["this-is-a-title-1"], "city_ids"=>[], "title"=>"This is a title", "excerpt"=>"This is a brief desc.", "content"=>"here's some content", "user_id"=>"4f69a0dfb0ac200001000001", "updated_at"=>2012-11-21 20:25:54 UTC, "created_at"=>2012-11-21 20:25:54 UTC, "version"=>1}] flags=[] (0.0994ms)
=> #<Article _id: 50ad38d2ebda22048b000006, _type: nil, _slugs: ["this-is-a-title-1"], created_at: 2012-11-21 20:25:54 UTC, updated_at: 2012-11-21 20:25:54 UTC, user_id: "4f69a0dfb0ac200001000001", city_ids: [], title: "This is a title", excerpt: "This is a brief desc.", content: "here's some content", published_at: nil, tags_array: nil, categories_array: nil, version: 1, modifier_id: nil, state: "draft">
First update:
#<Article _id: 50ad354aebda22048b000001, _type: nil, _slugs: ["this-is-a-title"], created_at: 2012-11-21 20:10:51 UTC, updated_at: 2012-11-21 20:10:51 UTC, user_id: "4f69a0dfb0ac200001000001", city_ids: [], title: "This is a title", excerpt: "This is a brief desc.", content: "here's some content", published_at: nil, tags_array: nil, categories_array: nil, version: 1, modifier_id: nil, state: "draft">
irb(main):006:0> c.update_attributes(:content => "This should fire the version")
MOPED: 10.254.66.79:27082 INSERT database=app3383995 collection=history_trackers documents=[{"_id"=>"50ad3591ebda22048b000003", "association_chain"=>[{"name"=>"Article", "id"=>"50ad354aebda22048b000001"}], "scope"=>"article", "original"=>{"content"=>"here's some content"}, "modified"=>{"content"=>"This should fire the version"}, "version"=>2, "action"=>"update", "updated_at"=>2012-11-21 20:12:01 UTC, "created_at"=>2012-11-21 20:12:01 UTC}] flags=[] (0.2418ms)
MOPED: 10.254.66.79:27082 UPDATE database=app3383995 collection=articles selector={"_id"=>"50ad354aebda22048b000001"} update={"$set"=>{"content"=>"This should fire the version", "updated_at"=>2012-11-21 20:12:01 UTC, "version"=>2}} flags=[] (0.0978ms)
Second update:
MOPED: 10.254.66.79:27082 INSERT database=app3383995 collection=history_trackers documents=[{"_id"=>"50ad35e2ebda22048b000004", "association_chain"=>[{"name"=>"Article", "id"=>"50ad354aebda22048b000001"}], "scope"=>"article", "original"=>{"content"=>"This should fire the version"}, "modified"=>{"content"=>"This should fire the another version"}, "version"=>3, "action"=>"update", "updated_at"=>2012-11-21 20:13:22 UTC, "created_at"=>2012-11-21 20:13:22 UTC}] flags=[] (0.1411ms)
MOPED: 10.254.66.79:27082 UPDATE database=app3383995 collection=articles selector={"_id"=>"50ad354aebda22048b000001"} update={"$set"=>{"content"=>"This should fire the another version", "updated_at"=>2012-11-21 20:13:22 UTC, "version"=>3}} flags=[] (0.0970ms)
#<Article _id: 50ad354aebda22048b000001, _type: nil, _slugs: ["this-is-a-title"], created_at: 2012-11-21 20:10:51 UTC, updated_at: 2012-11-21 20:13:22 UTC, user_id: "4f69a0dfb0ac200001000001", city_ids: [], title: "This is a title", excerpt: "This is a brief desc.", content: "This should fire the another version", published_at: nil, tags_array: nil, categories_array: nil, version: 3, modifier_id: nil, state: "draft">
irb(main):009:0> c.history_tracks
=> #<Mongoid::Criteria
selector: {"scope"=>"article", "association_chain"=>{"$elemMatch"=>{"name"=>"Article", "id"=>"50ad354aebda22048b000001"}}},
options: {},
class: HistoryTracker,
embedded: false>
irb(main):010:0> c.history_tracks.size
MOPED: 10.254.66.79:27082 COMMAND database=app3383995 command={:count=>"history_trackers", :query=>{"scope"=>"article", "association_chain"=>{"$elemMatch"=>{"name"=>"Article", "id"=>"50ad354aebda22048b000001"}}}} (8.2543ms)
=> 0
irb(main):011:0>
from mongoid-history.
Do the same in your local environment that works. What's the difference?
from mongoid-history.
They're almost identical adding to the weirdness.
MOPED: 10.254.66.79:27082 INSERT database=app3383995 collection=history_trackers documents=[{"_id"=>"50ad35e2ebda22048b000004", "association_chain"=>[{"name"=>"Article", "id"=>"50ad354aebda22048b000001"}], "scope"=>"article", "original"=>{"content"=>"This should fire the version"}, "modified"=>{"content"=>"This should fire the another version"}, "version"=>3, "action"=>"update", "updated_at"=>2012-11-21 20:13:22 UTC, "created_at"=>2012-11-21 20:13:22 UTC}] flags=[] (0.1411ms)
MOPED: 10.254.66.79:27082 UPDATE database=app3383995 collection=articles selector={"_id"=>"50ad354aebda22048b000001"} update={"$set"=>{"content"=>"This should fire the another version", "updated_at"=>2012-11-21 20:13:22 UTC, "version"=>3}} flags=[] (0.0970ms)
MOPED: 127.0.0.1:27017 INSERT database=recordapp collection=history_trackers documents=[{"_id"=>"50ad5f55cd1ea59a5e000004", "association_chain"=>[{"name"=>"Article", "id"=>"50ad5e06cd1ea59a5e000001"}], "scope"=>"article", "original"=>{"content"=>"This should fire the another version"}, "modified"=>{"content"=>"This should fire the another version sdfsdfsdfsd"}, "version"=>3, "action"=>"update", "updated_at"=>2012-11-21 23:10:13 UTC, "created_at"=>2012-11-21 23:10:13 UTC}] flags=[] (0.2029ms)
MOPED: 127.0.0.1:27017 UPDATE database=recordapp collection=articles selector={"_id"=>"50ad5e06cd1ea59a5e000001"} update={"$set"=>{"content"=>"This should fire the another version sdfsdfsdfsd", "updated_at"=>2012-11-21 23:10:13 UTC, "version"=>3}} flags=[] (0.1280ms)
from mongoid-history.
Mystery solved. Or at least identified. By process of elimination, I realized that the mongoid_fulltext search was the cause. I removed it, and now it works.
It makes a large number of calls each time a document is created or updated, I thought to take it out staring at the list of updates it makes. Somehow it interfered with the history tracking but only on the server. No idea why.
Thanks for the tips!
from mongoid-history.
I am going to close this, since it seems to be some combination of issue with another gem, but it would be great if you found time to track the root cause.
from mongoid-history.
Related Issues (20)
- Restrict dependency failure does not prevent history entry creation
- Unable to Contribute HOT 1
- undefined method `[]' for #<..::EmbedsMany> HOT 7
- Compatibility with Mongoid 7 HOT 4
- Specs create classes and are order-dependent
- Fix undo and redo modifier on embedded create/destroy
- Fix inheritance of history_trackable_options HOT 4
- Changing collection breaks history tracking HOT 5
- Release v. Next HOT 1
- `HistoryTracker` documents not created if `track_create` set to `false` HOT 2
- undefined method `collection_name' for nil:NilClass Did you mean? collectionize error coming HOT 6
- History tracker recording undo action as the last change.. HOT 1
- wrong number of arguments HOT 14
- Adding custom attributes before save HOT 1
- A tracker on an embeds_many relation is being limited by the parent configuration HOT 1
- Embeds many tracking fails if original value is `nil`
- How can we track changes done with set method? HOT 1
- It should not warn about `Overwriting existing field version` when `track_history` is called more than once
- Is it possible to specify a max number of history_tracks to maintain for each document? HOT 1
- How to get what the collection looked like on a version? HOT 3
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 mongoid-history.