我正在尝试为列中的值添加created at,例如,如果我添加了新发票,它将显示添加发票的日期,而不是添加案例的日期
<%= @case.invoice.created_at %>
这会得到null
在我数据库中
class AddAttachmentInvoiceToCases < ActiveRecord::Migration
def self.up
change_table :cases do |t|
t.attachment :invoice
end
end
def self.down
remove_attachment :cases, :invoice
end
end
在我架构中
create_table "cases", force: :cascade do |t|
t.string "pt_first_name"
t.string "pt_last_name"
t.date "date_received"
t.date "due_date"
t.string "shade"
t.string "mould"
t.string "upper_lower"
t.integer "user_id"
t.string "invoice_file_name"
t.string "invoice_content_type"
t.integer "invoice_file_size", limit: 8
t.datetime "invoice_updated_at"
t.string "implant_brand"
t.string "implant_quantity"
t.integer "number"
t.boolean "finished"
t.boolean "ship"
t.boolean "outsourced"
t.string "invoice2_file_name"
t.string "invoice2_content_type"
t.integer "invoice2_file_size", limit: 8
t.datetime "invoice2_updated_at"
t.string "invoice3_file_name"
t.string "invoice3_content_type"
t.integer "invoice3_file_size", limit: 8
t.datetime "invoice3_updated_at"
t.string "invoice4_file_name"
t.string "invoice4_content_type"
t.integer "invoice4_file_size", limit: 8
t.datetime "invoice4_updated_at"
t.string "invoice5_file_name"
t.string "invoice5_content_type"
t.integer "invoice5_file_size", limit: 8
t.datetime "invoice5_updated_at"
t.datetime "created_at"
t.datetime "updated_at"
end
1条答案
按热度按时间anauzrmj1#
在
Invoice
的迁移中,您是否有t.timestamps
?例如:
否则,您可能需要添加这些内容