ruby-on-railsruby-on-rails-3acts-as-taggable-onattr-accessible

how override attr_accessible role ActsAsTaggableOn::Tag model?


how override attr_accessible role for field :name in Tag model in ActsAsTaggableOn gem ?

I want some things like that in Tag model ...

attr_accessible :name, :as => [:default, :admin]

for allow me to edit field name of tag by admin role


Solution

  • You can monkey patch acts_as_taggable_on by creating a file in config/initializers and adding the following lines. Restart your rails server for changes to take effect.

    ActsAsTaggableOn::Tag.class_eval do
      attr_accessible :name, :as => [:default, :admin]
    end