2014-10-10 127 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}" 

刪除後標籤顯示正確。