-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Closed
Labels
bugbreakages in functionality that is implementedbreakages in functionality that is implemented
Description
- What were you trying to do?
I am defining someATTRIBUTE_TYPESin a dashboard. One of my attributes (lead_practitioners) is abelongs_torelation where its class name doesn't match the relation name. My model defines thisbelongs_torelation like so:
class Practice < ApplicationRecord
has_many :practitioner_practices, inverse_of: :practice, dependent: :destroy
has_many :practitioners, through: :practitioner_practices
has_many :lead_practitioners, -> { where(practitioner_practices: {lead: true}) }, through: :practitioner_practices, source: :practitioner
...- What did you end up with (logs, or, even better, example apps are great!)?
I am using theclass_nameoption when I define the attribute in the dashboard file, like this:
ATTRIBUTE_TYPES = {
...
lead_practitioner: Field::BelongsTo.with_options(class_name: "Practitioner"),
...
}which works, but warns me with this:
DEPRECATION WARNING: The option :class_name is deprecated. Administrate should detect it automatically. Please file an issue at https://github.com/thoughtbot/administrate/issues if you think otherwise.If I remove the class_name option and let the Administrate gem try to determine the class name on its own, I get this error:
ActionView::Template::Error:
undefined method `klass' for nil:NilClass
reflection(resource_class, attr).klassEven if I explicitly add the class name to the model relation, like so:
has_many :lead_practitioners, -> { where(practitioner_practices: {lead: true}) }, through: :practitioner_practices, source: :practitioner, class_name: "Practitioner"
I get the same error as above.
- What versions are you running?
- Rails: 7.0.4
- administrate: 0.18.0
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugbreakages in functionality that is implementedbreakages in functionality that is implemented