Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

attr_protected on cache_slugs #10

Closed
nono opened this issue Oct 22, 2009 · 4 comments
Closed

attr_protected on cache_slugs #10

nono opened this issue Oct 22, 2009 · 4 comments

Comments

@nono
Copy link
Contributor

nono commented Oct 22, 2009

Hi,

friendly_id automatically makes a call to attr_protected on the cache column. This is a good thing except when the model uses attr_accessible. In that case, Rails blows up: "Declare either attr_protected or attr_accessible for YourModel, but not both."

Maybe friendly_id should let the developer disable this :
has_friendly_id :title, :protected => false

@norman
Copy link
Owner

norman commented Oct 22, 2009

Ah, that's too bad - I didn't realize this would happen. I'd prefer not to add yet another option to friendly_id if I can avoid it. What you would think of overriding the #{cache_column}= method by default in order to protect it?

@nono
Copy link
Contributor Author

nono commented Oct 22, 2009

Not sure it's a good idea. I think it will break the way the cache column is assigned in the plugin but it can be changed.

@norman
Copy link
Owner

norman commented Oct 23, 2009

Ok, I have made it so that if attr_accessible has been invoked, attr_protected will not be used. This requires that the invocation of attr_accessible occur BEFORE the invocation of has_friendly_id, which is a little ugly and inconvenient, but I can live with it. I added documentation to the README and to the rdocs. New release coming shortly.

@nono
Copy link
Contributor Author

nono commented Oct 24, 2009

Cool, It works well for me, and I find that cleaner that overriding the #{cache_column}= method.

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants