Has_many_polymorphs tagging - works on development machine, not production!

I'm having a weird problem where tagging works fine on my development machine , but when I deploy to production server, I get this error in the log:

ActionView::TemplateError (undefined method `tags' for #<Person:0x98bb9d4>) on line...  

      

There is an entry in the production.log that says has_many_polymorphs has been loaded, so it doesn't look like a plugin that is not available on the production machine.

My google-fu didn't help me find the answer, so if anyone knows what might be wrong, we'd be very grateful!

Edit: I should have mentioned that in production and development, I use the same database. I downloaded a production product and used it on a development machine and it works great.

0


source to share


4 answers


I spent some time with a consultant tracking this and we ended up finding that the Tagging stuff just wouldn't load for unknown reasons.

By adding one line of code, just three letters, to the end of environment.rb, it was resolved. I commented this out so that we will never forget that wtf continued:

# Magic begins here.
# We need to force Rails to load the Tag record, or 
# has_many_polymorphs doesn't work properly. I don't know
# if there a better fix, but this one seems reasonable. :-/
Tag

      



That's all. I'm sure there is an elegant and correct solution out there, but it works. Weird.

I hope this helps someone out there.

0


source


cap deploy: migrations



0


source


I have seen similar issues where the polymorphic type field is not filled in correctly, or where some existing data was added before the polymorphic type was added. Is human a subclass? does the _type field have any null values ​​in the polymorph table?

0


source


It's easy to poke in the dark here, but has_many_polymorphs doesn't add tagging to your models. Instead, you use a generator to create a tagging extension module, which is included in lib / tagging_extensions.rb. The module file has helper methods that add tag functionality built on top of the has_many_polymorphs base function.

So, is it possible that you have a plugin installed but not a tag extension file?

0


source







All Articles