Skip to content

Commit

Permalink
Refactor conditional to OO
Browse files Browse the repository at this point in the history
  • Loading branch information
jamie authored and pablobm committed Jun 28, 2022
1 parent 34d4131 commit 051d846
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/administrate/field/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def self.associative?
end

def self.eager_load?
self <= BelongsTo || self <= HasOne
false
end

def self.searchable?
Expand Down
4 changes: 4 additions & 0 deletions lib/administrate/field/belongs_to.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ def self.permitted_attribute(attr, options = {})
end
end

def self.eager_load?
true
end

def permitted_attribute
foreign_key
end
Expand Down
4 changes: 4 additions & 0 deletions lib/administrate/field/has_one.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ def self.permitted_attribute(attr, options = {})
{ "#{attr}_attributes": related_dashboard_attributes }
end

def self.eager_load?
true
end

def nested_form
@nested_form ||= Administrate::Page::Form.new(
resolver.dashboard_class.new,
Expand Down

0 comments on commit 051d846

Please sign in to comment.