Polymorphic Associations and searching parent of parent
Here is a small gist of my model setup.
I'm using ransack to search the index page of the EmailLogs model and search by UserName. The Email Logs can belong to either a Notebook or a NotebookArticle, however, and the user is a direct parent to the notebook, while the notebookarticle's parent is the user whose parent is in turn the user.
I've looked at the documentation for polymorphic searches and can't quite get it to work. What I'm endeavoring to accomplish is something like this:
<%= f.search_field :email_loggable_of_Email_log_user_name_cont, :class => 'form-control', :id => 'q_traveler_last_name_or_user_first_name_cont', :placeholder => "Last, First" %>
However this doesn't seem to be the case, I get an error of uninitialized constant EmailLog::EmailLoggable. Does anyone have any tips?
I have also the class structure like this
module Custom
module Directory
class File
has_one :card, as: :card, class_name: "Custom::Card"
end
end
end
module Custom
class card
belongs_to :card, polymorphic: true
end
end
and I am adding the filter in active admin like card_of_Custom::Directory::File_type_card_id according to the documentation of https://activerecord-hackery.github.io/ransack/going-further/polymorphic-search/
but getting the error like :card_of_Custom is not a class/module.
ActiveAdmin Version is 2.12.0
Please help.