Acts_as_commentable release

wait…

controller
def view
@howto = Howto.find(2)
@howto.comments
end

and when i do the debug @howto, i see the comments…

but when i do without the @howto.comments, the comments are not
available in the view. is this right?

controller
def view
@howto = Howto.find(2)
end

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
unknown.

AR will not load the comments unless asked:
eg. @howto.comments
OR
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).

See

i really dont think i broke something, but anyone here ever had your
application stop adding comments to the database?

i can manually enter them in the comments table, but not in my rails
application!

hi askegg, thanks for pointing out that article. what you are describing
is exacyly how i plan on implenting acts as commentable.

askegg wrote:

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).

See
http://slash7.com/assets/2006/10/8/RJS-Demistified_Amy-Hoy-slash7_1.pdf

Check the logs for the SQL statements being made…

ahhhhhH!

i see my carelessness again!

add_comment vs add_comments!

thanks again askegg.

nah pizdetc

nah pizdetc

nah pizdetc

nah pizdetc

nah pizdetc

hey,

I installed&run the plugin successfully. it works with one exception
when I say @event.add_comment my_comment_object
it create 1 comment but 2 commentings.
so @event.comments returns the comments twice.

does any one has an idea why :slight_smile: