RuntimeError: declare either attr_protected or attr_accessible for the user, but not both

Since in a short time my rail applications cause the following runtime error in the test suite:

RuntimeError: Declare either attr_protected or attr_accessible for User, but not both.

This was probably introduced by the update for restful_authentication. But scanning the code for "attr_protected" shows that it is never called. So why is this error message?

My user model has only the following code:

attr_accessible :login, :email, :name, :password, :password_confirmation, :identity_url

So should it be all right? Any clues where to look for the problem? A google search shows a few strangers who also see this problem only in a test environment and sporadically in a development environment.

+3
source share
3 answers

If you use RestfulAuthentication with friendly_id, the latest version of friendly_id may bring this error, as indicated on the github page:

In addition, this function uses attr_protected to protect the cached_slug column if you have not already called attr_accessible. Therefore, if you want to use attr_accessible, you must call it before you call has_friendly_id in your class. github page

Also, when using grep to search for keywords, do not forget to grep also in gems, as you may have installed some plugins as a gem archive.

+6
source

include d User, attr_protected. , - .

0

This may be due to the addition of a plugin attr_protected. This may be helpful.

0
source

Source: https://habr.com/ru/post/1722254/


All Articles