suweller / mongoid-autoinc

⬆ Auto incrementing fields for Mongoid documents
MIT License
62 stars 44 forks source link

Undefined method 'attr_protected' for Class #32

Closed VicenteRD closed 7 years ago

VicenteRD commented 7 years ago

I'm getting the error when calling increments :var . (Ruby 2.3, Rails 5.0.1, Mongoid 6)

Looking at the source I can see you're using attr_protected, which is no longer used. http://stackoverflow.com/questions/17371334/how-is-attr-accessible-used-in-rails-4

I've also attached screenshot of the error screen

Am I doing something wrong?

Thanks in advance.

image

suweller commented 7 years ago

This is guarded since commit (953aa833c3c37b6910f01fcdd63c414d859f785b), which is included in v6.0.0.rc0, v5.0.2, v5.0.1, and v4.0.0.

What version are you using?

VicenteRD commented 7 years ago

gem 'mongoid', '~> 6.0', '>= 6.0.3'. But it seems to be a Rails version issue (Using 5.0.1) They're no longer using attr_protected in favor of strong parameters. I've managed to get a copy of your code working within my project, but I don't consider it an elegant solution, and I kind of didn't ask for permission...

suweller commented 7 years ago

I'm sorry for being unclear in my initial response. I meant: "Which version of mongoid-autoinc are you using?" I'm quite sure it does not assume attr_protected to be there. At least for the versions I've mentioned above.

VicenteRD commented 7 years ago

Oh, oops, sorry. I did not specify a version in the Gemfile... I'm guessing latest ?

suweller commented 7 years ago

I've released v6.0.0. I hope that, if you run bundle update mongoid-autoinc your problems will go away. Since I have no specific gem version for this gem, this is the best I can do for you.

VicenteRD commented 7 years ago

It works like a charm, I'm sorry for the ambiguity of my responses :/

Thanks a bunch!!