views:

258

answers:

2

Hi All, I am developing my first rails site (yup, i am a rails idiot). I'm writing a blog, and i got to the comments part. I installed acts-as-commentable-with-threading ( GitHub ), i made and ran the migration like the install instructions said. I have added acts_as_commentable to my Posts model and i have a Comments controller When i add

@comment = Comment.build_from(params[:id],1, params[:body] )

I get the error. undefined method `build_from' for #

Clearly i am doing something terribly wrong, and i don't really get the example. What should i be feeding to build_from? Can somebody explain this plugin step by step? :)

Or is there an easier way to get simple threaded comments?

A: 

Besides the reason of not restarting server (btw you shouldn't use nginx + passenger for development, simple mongrel or thin will do the job better in this case) I can think of two more:

  1. You didn't install plugin (or something wrong happened during installing). However this is unlikely as you could run migration ok right?
  2. You have comment model in app/models and rails doesn't load it from plugin. In this case you might want to try requiring file with plain old require.
Andrius
A: 

Did you by chance define your own comment model? If so that is going to completely override the model from the plugin that defines build_from in the first place. I ended up getting around this by creating a module with the extra stuff I wanted then creating an initializer to include it, which works perfectly.

As an aside, the first parameter to build_from needs to be the actual commentable object the comment is to be connected to, not just an id.

I'm currently using this plugin in production and can assure you it works :)

x1a4