ruby on rails - Is it possible to make a relationship between an ActiveRecord model and a plugin's model? -


I am using Ruby on Rail 2.3.8, and I have installed the works_as_taggable_on plugin for tagging announcements and all Something is fine till I came to know that I had no easy and clear way of tagging all the announcements (only the only way Tagged Tagwith Tagged_with (tag_name)) with a specific ID.

So, I just created the Active Model (model) for the tag model, a tagging model, which represents the tagging table, which is included inside the plugin.

Is it possible to do this?

It should be possible, if they are both ActiveRecord models.

To define a relationship in the plugin's model, you must do some metaprographic in a library, before you use it to use your environment. At the end of the RB file can stick it.

  ModelName.class_eval is has_many: announcements end  

This can be specially or not work, but this is the basic idea.

If metaprograding proves to be very complicated, then you can always do this (here's a perception about schema, I have not used AAT in a few years):

Taggings.find_by_tag_id_and_user_id (@tag. Id, @ user.id,: included =>: user) .map {| T | T.user)}


Comments