This might be completely off the mark, but you use @posts then @post?
+1
A:
dain
2010-06-09 10:55:32
nope, not that. thanks, though!
yuval
2010-06-12 03:25:14
+1
A:
ArgumentError in CommentsController#create
wrong number of arguments (2 for 0)
You get this error because @comment is not the object you expect. Try to debug this by inserting:
logger.debug @comment.inspect
You'll see something unexpected and it should raise at least an eyebrow. This should be the clou that you assigned the Post.find(...)
to @posts
but later tried to work with @post
.
hurikhan77
2010-06-11 07:36:36
+1
A:
I ran through a sample rails app with your code and it all worked fine for me.
I would suggest debugging a little more like hurikhan77 is suggesting and see if it is just the @posts / @post issue that dain suggested.
Also, try creating a post and a comment in the console with some very simple content to see if it is working.
$ ruby script/console
# add whatever fields are necessary to create
> @p = Post.create(:title => "TestPost1")
# => #<Post id: 3, ...
# again, add whatever is necessary to create
> @c = @p.comments.create(:comment => "TestComment1")
# => #<Comment id: 8, ...
> Post.find(:last).comments_count
# => 1
See what that gets you.
/ JP
Josh Pinter
2010-06-11 17:55:33