Ruby on Rails Monday, October 12, 2015

I'm trying to run migration to allow translation of tags with Globalize gem.

I've added config/initializers/acts_as_taggable_on.rb with following content:
ActsAsTaggableOn::Tag.class_eval do
  translates
:name
end

Running "bundler exec rake db:migrate" fails with error message:
undefined method `translates' for #<Class:0xba5eea10> (NoMethodError)

Is something I missing here?

On Monday, January 14, 2013 at 12:54:43 PM UTC+2, Tommaso Visconti wrote:
Erwin ha scritto:
> I am using the gem 'acts-as-taggable-on' ( mbleigh) and I need to extend
> the Tag model to translate the tag name with Globalize
> How can I add "translates :name" into ActsAsTaggableOn::Tag ? I can fork
> the gem and modify my version, but is there any way to do it simply with
> "extend ActiveSupport::Concern" ?

You can decorate the class:

ActsAsTaggableOn::Tag.class_eval do
   translate :name
end

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/5ef304b4-5429-4446-83f5-f30b0a23a691%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment