acts_as_commentable release

You (the user) are adding comments to the recipe, so
acts_as_commentable expects a table called "user" with an id field.
There is no need to change the tables as the association is polymorphic
(it can apply to any model), hence the commentable_type and
commentable_id fields.

My README file defines a comments table - not sure where you are
getting the commentings from....

How are you calling up the comments to produce that error?

Hmmm, the copy I have does not include any mention of a commentings
table - I think I can safely ignore it. Perhaps you should make sure
you have the latest version first?

The comments table schema looks exactly the same as mine. The usage in
the controller looks OK, but what does the getHowTo method in the HowTo
model do?

The relationship between the Howto model should be built by the plugin:

class Howto < ActiveRecord::Base

So long as there is a user account with an id field, comments should be
happy. This should not really matter unless you are searching for
comments by a particular user.

You should not need to add anything to the comment.rb file as you are
not asking "which of all these comments belongs to this howto?" but
"Given this howto, what are the comments made?". The difference is in
the direction of the question.

Do me a favor? First restart your webserver and view the page - it
might work. Then refresh the page without restarting (it might fail).
Repeat to make sure. There may be a bug in the plugin (I am
experiencing similar issues).

After that - have a look at your custom getHowto method and get back to

Try it, but you shouldn't need to.
The plugin adds the methods for you.

poipu wrote:

when i do this

@howto = Howto.find(id)

and print out the @howto via debug in my view, i dont see any
association to the acts_as_commentable. because of this i guess thats
the reason why @howto.add_comment(c) doesnt work...

No, you wont because the method find returns a Howto object, which does
not describe the methods available on the object. If you want to see
these, start a console (./scripts/console) and type:


You should see add_comment listed....

Ahh - your self.getHowto method might be returning an array of howTo's.
Arrays are not extended by acts_as_commentable, so the method is

AR will not load the comments unless asked:
eg. @howto.comments
Howto.find(params[:id], :include =" :comments)

Of course this is different to displaying them or not. You may want to
use your view to display howtos without comments first, them a use a
link to display a version *with* comments.

The first loads the comments into the instance variable @comments,
which can be used in your view. The second does not because .comments
is never called or stored.

If you get fancy you can create a method to spit back the comments only
and use ajax to populate a div to display them, with some fancy
animation of course. That way you do not need to create two different
views, you do not load comments by default and you can display your
web2.0 prowess with little effort (thanks to rails magic).


poipu wrote:

Check the logs for the SQL statements being made....