2014-10-10 94 views
0

出于某种原因,轨道full_messages缺少标签和仅包含错误,没有任何线索,它涉及领域:Rails的full_messages缺少标签

[3] pry(#<Spree::CheckoutController>)> @order.errors 
=> #<ActiveModel::Errors:0x007fce1caa8218 
@base= 
    #<Spree::Order id: 87, number: "R442456123", item_total: #<BigDecimal:7fce1c57a4a8,'0.6495E2',18(36)>, total: #<BigDecimal:7fce1c5cd0e0,'0.6495E2',18(27)>, state: "address", adjustment_total: #<BigDecimal:7fce1c5cd270,'0.0',9(27)>, user_id: 57, completed_at: nil, bill_address_id: nil, ship_address_id: nil, payment_total: #<BigDecimal:7fce1cb184a0,'0.0',9(27)>, shipping_method_id: nil, shipment_state: nil, payment_state: nil, email: "[email protected]", special_instructions: nil, created_at: "2014-10-10 09:47:21", updated_at: "2014-10-10 09:47:24", currency: "USD", last_ip_address: "127.0.0.1", created_by_id: 57, channel: "spree", tax_total: #<BigDecimal:7fce1cb217d0,'0.0',9(27)>>, 
@messages= 
    {:"bill_address.phone"=>["can't be blank"], 
    :"ship_address.phone"=>["can't be blank"]}> 
[4] pry(#<Spree::CheckoutController>)> @order.errors.full_messages 
=> ["can't be blank", "can't be blank"] 

我已经添加在en.yml属性 - 怎么办我得到充分的信息包含的型号名称,即:["Billing address phone can't be blank", "Shipping address phone can't be blank"]

使用下列内容:

gem 'rails', '4.0.2' 
gem 'spree', '2.1.4' 

回答

0

我想你在添加属性的方式en.yml文件错误。你应该这样做:

en: 
    activerecord: 
    attributes: 
     spree/order/bill_address: 
     phone: Billing address phone 
     spree/order/ship_address: 
     phone: Shipping address phone 
+0

其实狂热的核心已经有这些翻译,所以我删除了我的条目。但由于它们已经存在于spree_core/config/en.yml中,它可能不是。谢谢你的帮助。 – Nick 2014-10-10 14:27:46

1

对我来说,这是一个在我的en.yml中存在(以前一直被遗忘的原因)以下问题。

errors: 
    format: "%{message}" 

删除后标签显示正确。