Ok, now I got the breakpointer working, but for some reason, my comments
are still not saving.
I’m going to post everything that I have and hopefully someone will be
able to tell me where I’m going wrong…
Here is my controller code:
def comment
post = Post.find(params[:id])
@comment = post.post_comments.build(params[:post_comment])
breakpoint
if @comment.save
flash[:notice] = “Added your comment.”
redirect_to :action => “show”, :id => params[:id]
else
flash[:notice] = “Unable to save your comment.”
redirect_to :action => “show”, :id => params[:id]
end
end
And here is what I’m getting in my log as a result:
Processing BlogController#comment (for 127.0.0.1 at 2006-11-01 22:45:25)
[POST]
Session ID: fc25db96c14d3bf349e3e52cbd311bcc
Parameters: {“post_comment”=>{“body”=>“test”}, “commit”=>“Comment!”,
“action”=>“comment”, “id”=>“3”, “controller”=>“blog”}
Post Load (0.000826) SELECT * FROM posts WHERE (posts.id = ‘3’)
LIMIT 1
Post Columns (0.006130) SHOW FIELDS FROM posts
PostComment Load (0.007839) SELECT * FROM post_comments WHERE
(post_comments.post_id = 3)
PostComment Columns (0.020313) SHOW FIELDS FROM post_comments
SQL (0.000301) BEGIN
SQL (0.000296) COMMIT
Redirected to http://0.0.0.0:3000/blog/show/3
Completed in 5.10297 (0 reqs/sec) | DB: 0.03571 (0%) | 302 Found
[http://0.0.0.0/blog/comment/3]
Processing BlogController#show (for 127.0.0.1 at 2006-11-01 22:45:31)
[GET]
Session ID: fc25db96c14d3bf349e3e52cbd311bcc
Parameters: {“action”=>“show”, “id”=>“3”, “controller”=>“blog”}
Post Load (0.000811) SELECT * FROM posts WHERE (posts.id = ‘3’)
LIMIT 1
Rendering within layouts/application
Rendering blog/show
Post Columns (0.007676) SHOW FIELDS FROM posts
PostComment Load (0.014388) SELECT * FROM post_comments WHERE
(post_comments.post_id = 3)
Completed in 0.11120 (8 reqs/sec) | Rendering: 0.07924 (71%) | DB:
0.02288 (20%) | 200 OK [http://0.0.0.0/blog/show/3]
At the breakpoint in my above controller code, here is the value of
@commment:
@comment
=> #<PostComment:0x26bcce4 @new_record=true,
@attributes={“body”=>“test”, “date”=>nil, “created_by”=>nil,
“post_id”=>3, “website_address”=>nil, “email_address”=>nil}>
Here is my post_comments table:
CREATE TABLE post_comments
(
id
int(11) NOT NULL auto_increment,
body
text NOT NULL,
created_by
varchar(255) default NULL,
email_address
varchar(255) default NULL,
website_address
varchar(255) default NULL,
date
datetime default NULL,
post_id
int(11) NOT NULL,
PRIMARY KEY (id
)
) ENGINE=MyISAM AUTO_INCREMENT=1 DEFAULT CHARSET=latin1 AUTO_INCREMENT=1
;
I’m at a loss at this point. It seems like I’ve tried everything, but
I’m sure I’m missing something minor.
Any help will be appreciated.
Thanks,
Luke