The tags are stored in the Tags table, which you access from your program with e.g.
ActsAsTaggableOn::Tag.all
If you need more info on tag usage, there is also the table
ActsAsTaggableOn::Tagging
which contains links to where each tag is being used, including its context
To further apply this to your example, you can use
ActsAsTaggableOn::Tagging.includes(:tag).where(context: 'deshanatags').map { |tagging| { 'id' => tagging.tag_id.to_s, 'name' => tagging.tag.name } }.uniq
Let's explain the various parts in this statement:
- the 'includes' makes sure the different tags are "eager loaded", in other words, that instead of loading n+1 records, only 2 queries will be done on the database
- the 'where' limits the records to the ones with the given context
- the 'map' converts the resulting array of records into a new array, containing the hashes you asked for in your problem, with id mapped to the tag's id, and name mapped to the tag's name
- finally the 'uniq' makes sure that you don't have doubles in your list
To also cope with your additional problem, being taggins without tag, you could extend the where clause to
where("(context = 'deshanatags') AND (tag_id IS NOT NULL)")