:phone
(@@address_attribute
)의 별명 (예 : :phone_no
)을 추가하고 싶습니다. 내가 어떻게 해?속성에 별명을 추가하는 방법
module Spree
module Api
module ApiHelpers
ATTRIBUTES = [
:product_attributes,
:product_property_attributes,
:variant_attributes,
:image_attributes,
:option_value_attributes,
:order_attributes,
:line_item_attributes,
:option_type_attributes,
:payment_attributes,
:payment_method_attributes,
:shipment_attributes,
:taxonomy_attributes,
:taxon_attributes,
:inventory_unit_attributes,
:return_authorization_attributes,
:address_attributes,
:country_attributes,
:state_attributes,
:adjustment_attributes,
:inventory_unit_attributes,
:return_authorization_attributes,
:creditcard_attributes,
:payment_source_attributes,
:user_attributes,
:property_attributes,
:stock_location_attributes,
:stock_movement_attributes,
:stock_item_attributes
]
mattr_reader *ATTRIBUTES
def required_fields_for(model)
required_fields = model._validators.select do |field, validations|
validations.any? { |v| v.is_a?(ActiveModel::Validations::PresenceValidator) }
end.map(&:first) # get fields that are invalid
# Permalinks presence is validated, but are really automatically generated
# Therefore we shouldn't tell API clients that they MUST send one through
required_fields.map!(&:to_s).delete("permalink")
# Do not require slugs, either
required_fields.delete("slug")
required_fields
end
@@address_attributes = [
:id, :firstname, :lastname, :full_name, :address1, :address2, :city,
:zipcode, :phone, :company, :alternative_phone, :country_id, :state_id,
:state_name, :state_text
]
end
end
end
가능한 중복 클래스 속성 때문에 싱글 톤 클래스에 별칭을 할 필요가 .com/questions/6740379/ruby-alias-a-method-from-class) – Upperstage
-1 이렇게 긴 목록을 게시하십시오. 귀하의 요점을 보여주기 위해 그러한 긴 목록을 작성할 필요는 없습니다. – sawa