0

I'm using act_as_taggable_on with Devise.
Each user can set up their tags up to 3tags maximum on their profile edit page.
Before it does save, I'd like to have transaction something like this below. This is the one I implemented for my community model that is made by scaffold.

params[:community][:tag_list] = params[:community][:tag_list].gsub(/[ ]+/," ")
params[:community][:tag_list] = params[:community][:tag_list].gsub(/[.]+/,",")

I have no idea when doing this using Devise on side.

HUSTEN
  • 5,117
  • 4
  • 24
  • 38

1 Answers1

1

Move the code to Model to handle this functionality.

alias_method :super_tag_list=, :tag_list=
def tag_list=(tag_names)
  self.super_tag_list = tag_names.gsub(/[ ]+/," ").gsub(/[.]+/,",")
end
siddick
  • 1,478
  • 1
  • 14
  • 15