I have 2 models:
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
...
and the migration:
class CreateMicroPosts < <ActiveRecord::Migration
def change
create_table :micro_posts do |t|
...
And when I called add_post on heroku server, I got an error:
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'
But the wired thing is, it worked on my computer. My OS info:
ubuntu 10.04
ruby 1.9.3p0
rails 3.1.3
postgresql 8.4.10
Thanks.