Hi All, I am using the acts_as_commentable plugin (http://www.juixe.com/projects/acts_as_commentable) and have struck a slight issue. I have a number of models that use acts_as_commentable (news, events & documents) that typically look like: class News < ActiveRecord::Base belongs_to :user acts_as_commentable end The controllers are like: class NewsController < ApplicationController ... def show @news= News.find(params[:id]) @comments = @news.comments end ... end And the view: News--- <%= render :partial => ''/comments/comment'', :collection => @comments %> Comments --- <%= comment.title %> <%= comment.user.fullname %> 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. Any hints? --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
More info for you hackers: 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.... --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---