Open
Description
I created a custom parser to remove the # sign from the start of any tags that a user enters in:
class NoHashTagsParser < ActsAsTaggableOn::GenericParser
def parse
ActsAsTaggableOn::TagList.new.tap do |tag_list|
tag_list.add @tag_list.split(',').inject([]) {|res, tag| res << (tag.starts_with?('#') ? tag[1..-1] : tag)}
end
end
end
ActsAsTaggableOn.force_lowercase = true
ActsAsTaggableOn.default_parser = NoHashTagsParser
So if they enter in "this,#is,a,#test" it will save it, correctly, as [this,is,a,test]. that works fine. However the parser seems to get called every time I want to loop through the tags as well, which results in an error like this:
undefined method `starts_with?' for ["testing"]:Array
how can I have a custom parser that works on save only?
Metadata
Metadata
Assignees
Labels
No labels