我有2種型號:插入到在Heroku數據庫錯誤,但本地工作,ActiveRecord的:: StatementInvalid
class User < ActiveRecord::Base
has_many :micro_posts, :dependent => :destroy
..
def add_post(post)
self.micro_posts << post
end
class MicroPost < ActiveRecord::Base
belongs_to :user
...
和遷移:
class CreateMicroPosts < <ActiveRecord::Migration
def change
create_table :micro_posts do |t|
...
當我打電話的Heroku服務器上add_post,我出現錯誤:
2012-02-06T02:59:58+00:00 app[web.1]: ActiveRecord::StatementInvalid (ArgumentError: wrong number of arguments (1 for 0): INSERT INTO "micro_posts" ("created_at", "description", "pub_date", "tag", "title", "updated_at", "url", "user_id") VALUES ($1, $2, $3, $4, $5, $6, $7, $8) RETURNING "id"):
2012-02-06T02:59:58+00:00 app[web.1]: app/models/user.rb:25:in `add_post'
但有線的東西是,它在我的電腦上工作。我的操作系統信息:
ubuntu 10.04
ruby 1.9.3p0
rails 3.1.3
postgresql 8.4.10
謝謝。
我不能看到第一眼什麼你的代碼錯誤。不過我注意到你正在運行PostgreSQL 8.4,因爲Heroku在9.0.4(甚至9.1)的地方運行。嘗試升級您的Postgres並查看是否可以在本地重現錯誤。這會給你更詳細的記錄。 – Ariejan 2012-02-06 15:38:07
謝謝。我會升級它並嘗試。 – 2012-02-07 01:05:50
NO。我將postgresql升級到9.1.2(從源代碼構建),它在本地工作。 – 2012-02-07 02:50:35