我正在使用国家宝石和国家选择宝石。
我的电话表中有一个名为 :country_code 的属性。我要求新电话表单中的用户选择他们的国家:
<%= f.input :country_code, label: false, wrapper: :vertical_input_group do %>
<span class="input-group-addon">Country</span>
<%= country_select("phone", "country_code", {priority_countries["AU", "GB", "NZ"], selected: "AU" }, class: "form-control" ) %>
<% end %>
我想拿那个国家并获得国际前缀。
我有一个手机型号,我有:
def landline_number
[international_code, area_code, phone_number].join(' ')
end
def international_code
self.country_code = ISO3166::Country[country_code]
country_code.translations[I18n.locale.to_s] || country_code.international_prefix
end
当我尝试:
<%= @phone.landline_number %>
它打印国家名称而不是国际前缀。
如何让它打印一个数字而不是国家名称?