0
目前,我在軌道上4.1,如何在rails 4.1中檢索自動遞增的ID?
我有一個名爲accounts.rb
模型,
account = Account.create :name => 'test' :info => 'test'
所以這種說法是保存到數據庫,然後 我使用「account.id」的自動增量ID在帳戶表中。
但不工作,並顯示以下錯誤,
undefined method `id' for "":String
但這是在軌工作1.9版本。
請幫幫我。
你是不是缺少一個逗號呢? –
只需在記錄創建後使用'account.id' – Nithin
我沒有看到任何問題,對我來說工作得很好。你可以發佈'accounts.rb'嗎? –