Open francelwebdev opened 4 years ago
From README, "This gem supports Mongoid 3, 4, 5 on Ruby 1.9.3 or newer and Mongoid 6 and 7 on Ruby 2.2.2+." and Travis CI, https://github.com/mongoid/mongoid-history/blob/master/.travis.yml#L15.
However if I am reading your mind correctly you're having issues with Mongoid 7.1, similar to https://github.com/mongoid/mongoid-locker/issues/85. Appreciate a pull request with a fix.
Good evening, I get this error (wrong number of arguments (given 2, expected 1)) when I go to the index page of my companies controller. Below the code of my company model. I use ruby 2.7.1 and Rails 6.0.2.2 and latest mongoid-history.
`class Company
include Mongoid::Document
include Mongoid::Timestamps
# include Mongoid::Attributes::Dynamic
include Mongoid::History::Trackable
field :name, type: String
field :roles, type: Array
field :website, type: String
field :address, type: String
field :country, type: String
field :phone_number, type: String
field :email_address, type: String
field :tax_identification_number, type: String
field :rccm, type: String
paginates_per 1
track_history(:on => [:fields]) # all fields will be tracked
index({name: 1, tax_identification_number: 1, rccm: 1, email_address: 1, phone_number: 1, website: 1}, {unique: true})
has_many :contacts, class_name: "Contact", dependent: :delete_all
accepts_nested_attributes_for :contacts, reject_if: :all_blank, allow_destroy: true
has_many :customer_proformas, class_name: 'CustomerProforma', dependent: :delete_all
has_many :supplier_proformas, class_name: 'SupplierProforma', dependent: :delete_all
has_many :purchase_orders, class_name: "PurchaseOrder", dependent: :delete_all
has_many :customer_invoices, class_name: 'CustomerInvoice', dependent: :delete_all
has_many :supplier_invoices, class_name: 'SupplierInvoice', dependent: :delete_all
validates :name, presence: true, uniqueness: { case_sensitive: false }
validates :roles, presence: true
validates :phone_number, uniqueness: true, allow_blank: true
validates :email_address, uniqueness: true, allow_blank: true
validates :website, uniqueness: true, allow_blank: true
validates :tax_identification_number, uniqueness: true, allow_blank: true
validates :rccm, uniqueness: true, allow_blank: true
before_create :transformer_le_nom_de_lentreprise_en_majuscule
private
def transformer_le_nom_de_lentreprise_en_majuscule
self.name.upcase!
end
end `
Please help. Make a PR that uses Mongoid 7.1, demonstrate the failure, try to fix.
This is a bug in Mongoid 7.1.0. https://jira.mongodb.org/browse/MONGOID-4849
Hello, Okay, thank you. I'm going to try this to see if it solves the problem. Thanks again.
I am now using version 7.0.6 of Mongoid and I get this error (undefined method `collection_name' for Company:Class) when I update the index page of the controller companies.
@francelwebdev Help us help you?
export MONGOID_VERSION=7.0.6
, bundle install
, rake
) and see what fails. Hi, I still haven't found a solution to my problem. When I make rails console and instantiate my model with CustomerProforma.new, I get this error: ArgumentError: wrong number of arguments (given 2, expected 1) from /home/francel/.asdf/installs/ruby/2.7.1/lib/ruby/2.7.0/forwardable.rb:130:in
instance_delegate'
`.
ArgumentError: wrong number of arguments (given 2, expected 1) from /home/francel/.asdf/installs/ruby/2.7.1/lib/ruby/2.7.0/forwardable.rb:130:in
instance_delegate'
`
please help me solve the problem.
@francelwebdev Did you do what I suggested in https://github.com/mongoid/mongoid-history/issues/238#issuecomment-613456001?
Sorry, I am a beginner and I do not master that. Here is the project repository. https://github.com/francelwebdev/jmaplus_erp_crm.git
This project is a safe place for you to try and figure it out @francelwebdev! Here to help. You should definitely be able to do 1-3 above. I'll do my best to look at a fix if you can get those in.
FYI I have a project that uses Mongoid 7.1.2 and mongoid-history 0.8.2, I don't think I read history in any capacity but at least everything loads and I assume writes.
Hi,
I've been experiencing the same issue when trying to upgrade my app to Rails 6.
I cloned mongoid-history's repository and ran the tests as suggested by @dblock in this comment. I could not reproduce any problems there. Everything worked well and the tests passed.
After more investigation, I noticed that in my case this problem only happens in classes that include both Mongoid::History::Trackable
and Mongoid::Locker
, such as:
class Foo
include Mongoid::Document
include Mongoid::Timestamps
include Mongoid::Locker
include Mongoid::History::Trackable
track_history on: [:all], modifier_field_optional: true
end
The including order does not make any difference. However, if you call track_history
before including the Mongoid::Locker
, it will work fine:
class Test
include Mongoid::Document
include Mongoid::Timestamps
include Mongoid::History::Trackable
track_history on: [:all], modifier_field_optional: true
include Mongoid::Locker
end
A similar workaround is suggested here.
Below are the versions of related gems:
Current fix:
Hi, This gem supports Mongoid 7?