Class: RailsAdmin::Config::Fields::Types::HasOneAssociation

Inherits:
Association
  • Object
show all
Defined in:
lib/rails_admin/config/fields/types/has_one_association.rb

Instance Attribute Summary

Attributes inherited from Base

#abstract_model, #defined, #name, #order, #parent, #properties, #root, #section

Attributes included from Proxyable

#bindings

Instance Method Summary collapse

Methods inherited from Association

#associated_model_config, #associated_object_label_method, #associated_primary_key, #association, #foreign_key, #polymorphic?, #value, #virtual?

Methods inherited from Base

#association?, #errors, #form_default_value, #form_value, #generic_field_help, #generic_help, #initialize, #inspect, #inverse_of, #optional, #optional=, #optional?, #parse_input, #type, #type_css_class, #value, #virtual?

Methods included from Groupable

#group

Methods included from Hideable

#hidden?, #hide, included, #show

Methods included from Configurable

#has_option?, #register_deprecated_instance_option, #register_instance_option

Methods included from Proxyable

#with

Constructor Details

This class inherits a constructor from RailsAdmin::Config::Fields::Base

Instance Method Details

#editable?Boolean

Returns:


28
29
30
# File 'lib/rails_admin/config/fields/types/has_one_association.rb', line 28

def editable?
  (nested_form || abstract_model.model.new.respond_to?("#{name}_id=")) && super
end

#method_nameObject


36
37
38
# File 'lib/rails_admin/config/fields/types/has_one_association.rb', line 36

def method_name
  nested_form ? "#{name}_attributes".to_sym  : "#{name}_id".to_sym
end

#multiple?Boolean

Returns:


40
41
42
# File 'lib/rails_admin/config/fields/types/has_one_association.rb', line 40

def multiple?
  false
end

#selected_idObject


32
33
34
# File 'lib/rails_admin/config/fields/types/has_one_association.rb', line 32

def selected_id
  value.try :id
end