Activating the restriction accessors for acts_as_textiled
Reported by Jeff Richardson | April 1st, 2007 @ 12:49 PM
I think I have found a bug in acts_as_textiled. In my app, I'm using RedCloth 3.0.3 and I need to make sure that textiled attributes enforce the hard_breaks rule. So my model has a declaration like this:
acts_as_textiled :description, {:hard_breaks => true}
In order to get version 0.2 to honor my request, I had to change a line in acts_as_textiled.rb.
ORIGINAL:
textiled[attr.to_s] ||= RedCloth.new(read_attribute(attr), Array(ruled[attr])).to_html if read_attribute(attr)
PATCH:
textiled[attr.to_s] ||= RedCloth.new(read_attribute(attr), ruled.keys).to_html if read_attribute(attr)
It also appears to me that the following line is unnecesary (and possibly harmful), so I removed it.
attrs += ruled.keys
A diff is attached. This plug-in was a life-saver and your Rail Toolbox is a pot of gold.
--Thanks
Comments and changes to this ticket
-
Jeff Richardson April 1st, 2007 @ 12:49 PM
There's no bug, my mistake!
I just needed to do this:
acts_as_textiled :description => [:hard_breaks]
Sorry!
-
Chris Wanstrath April 1st, 2007 @ 12:49 PM
- State changed from new to resolved
- Assigned user set to Chris Wanstrath
Cool!
Please Sign in or create a free account to add a new ticket.
With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป