Assuming I understand your question is that you have multiple accounts, each with its own set of tags, which can be applied to any application model that calls act_as_taggable. The following should do what you want.
You can add the following to the application controller to make the subdomain available for all actions.
class ApplicationController < ActionController::Base before_filter :getSubdomain def getSubdomain @current_subdomain.(self.request.subdomains[0]) end end
Assuming you bind a tag to a subdomain in some way, like in your database, you can create a named scope. This example assumes that the subdomain is the username and your tag model belongs to the user, then you can use the named scope in your tag model to select only those that belong to the subobject.
class Tag < ActiveRecord::Base ... named_scope :find_by_subdomain, labmda do |subdomain| { :joins => "users ON users.id = tags.user_id", :conditions => ["users.name = ?", subdomain] } end end
Then, to retrieve tags in messages that were created by the user associated with the subdomain: Posts.tags.find_by_subdomain(@subdomain)
NB: you need to increase the tag model provided by act-as-taggable-on-steroids to add the following. - A column that associates each tag with an account. - Check the uniqueness for the scope. Allow multiple accounts with the same tags.
source share