Closed gzigzigzeo closed 13 years ago
Hey there Victor, Cheers for the awesome patch. Would it be possible before I pull it in to get should_convert_cached_slug to take into account an option on is_sluggable like :editable so that people can turn this feature on and off?
Cheers
Yes, of course. I think it would be useful to disable changing of cached_slug attribute when :editable is set to false, woulnd'nt it?
Let me explain. Let we have a model without my patch.
class Model < ActiveRecord::Base is_sluggable :name end
m = Model.create!(:name => "first") # slug will be "first" m.update_attribute(:name => "second") # slug will be "second" m.update_attribute(:cached_slug => "!!!invalid") # slug will be "!!!invalid", even it is not editable, but I think user should not be able to change this
I conjecture that it can be done by making cached_slug= setter protected when defined, but I am not yet shure. What do you think about it?
Possibly - I think personally the onus is on the app developer to manage attr_protected / attr_accessible (and mixing them is a bad idea) - Maybe changing the setter method to not work / do nothing would be an alternative solution? In general I like idea, I just dislike the notion of using attr_protected / attr_accessible like that.
Okay, let user decide to protect this attr. I'll send a message to you when finish.
I have made an :editable option, see tests/editable.rb. See my commit and merge if it is possible or tell me what should I fix.
Merged in and released as 0.4.0 - cheers for the contribution!
Thank you. You have made very useful plugin.
I have implemented manual slug edition functionality and wrote tests. See my message in closed issues.