Since a short time my rails applications yields 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 an update to restful_authentication. But scanning the code for "attr_protected" only shows me it is never called. So why this error message?
My user model only has the following code:
开发者_如何学运维attr_accessible :login, :email, :name, :password, :password_confirmation, :identity_url
So it should be perfectly okay? Any clues where to look for the problem? Searching google shows a few clueless people who also see this problem only in test environment and sporadically in the development environment.
If you are using RestfulAuthentication with friendly_id, the latest version of friendly_id can bring this error as indicated on the github page:
Also, this feature uses attr_protected to protect the cached_slug column, unless you have already invoked attr_accessible. So if you wish to use attr_accessible, you must invoke it BEFORE you invoke has_friendly_id in your class. github page
Also, when using grep to find occurences of keywords, don't forget to grep also in gems as you may have installed some plugins as gem archive.
You might have include
d modules into the User
class that declare attr_protected
. Maybe some kind of testing functionality does that.
This could be due to a plugin adding attr_protected
. This might be helpful.
精彩评论