I have rails4 app. It has (among others) Client
and Developer
models. I also have Submission
model.
I use activeadmin with cancan gems.
I try to make Submission
's comments to be visible for both Client
and Developer
(which are related to certain submission
), but when I check, developer
only sees his comments and client
correspondingly his. Assume, it has something to do with Ability
class definitions. Here is mine (partially):
def developer_rules(developer)
can [:read, :create], ActiveAdmin::Comment
end
def client_rules(client)
can [:read, :create], ActiveAdmin::Comment
can :manage, Client, id: client.id
end
Has anyone faced anything similar? Would be grateful for any hints. Thank you!
UPD: SOLVED
Eventually, issue has nothing to do with Ability
class.
ActiveAdmin shows comments separately for every namespace (even though these comment are associated to same resource), therefore the solution is to override this method
def self.find_for_resource_in_namespace(resource, namespace)
where resource_type: resource_type(resource),
resource_id: resource_id_cast(resource),
namespace: namespace.to_s
end
deleting last line namespace: namespace.to_s
so that comments are shown independent of namespace.