This last line references a function in the user model:
def fullname
"#{firstname} #{surname}"
end
When there are no comments attached to the news, events and documents
display correctly (probably because the comments code is not called).
When I add a comment I get the error:
"undefined method 'fullname' for #<User:0x92836498>"
This is really weird because I have a comments controller that uses the
same calls, partials etc, but displays the comments as expected.
I thought I discovered the problem when the CommentControler was
returning class "Comment", but the NewsController was returning class
"Comments" (note the extra s).
So, I removed all the references to "Comments" I could find to leave
all the model plumbing to acts_as_commentable (which I can now see does
all this for you).
That did not fix the issue, in fact things are even more bizzare than I
first thought....
If I view a news/event/document with comments the first pass works
fine. Hit refresh and you get an error (undefined method). WTF?
The SQL is slightly differnet as well - on the first pass we get"
SELECT * FROM comments WHERE (comment.commentable_id=5 AND
comment.commentable_type = "News')
SHOW FIELDS FROM comments
SHOW FIELDS FROM users
SELECT * FROM users WHERE (users.id = 1)
The second pass:
SELECT * FROM comments WHERE (comment.commentable_id=5 AND
comment.commentable_type = "News')
SHOW FIELDS FROM users
SELECT * FROM users WHERE (users.id = 1)
The "SHOW FIELDS FROM comments" goes missing? Is this normal? What
does it mean?
Anyway, I am off to a long "business" lunch to ponder, drink and ponder
some more....