“Undefined local variable or method” error when using commontator gem for comments

社会主义新天地 提交于 2019-12-01 21:25:01

As there is no stacktrace added, a couple of observations.

  1. acts_as_commontator and acts_as_commontable are added in same model.

    As per documentation at https://github.com/lml/commontator

    • acts_as_commontator // to be added in user model(s) (or any models that should be able to post comments)
    • acts_as_commontable // to be added in models you want to be able to comment on

      So can you try moving acts_as_commontator to user model?

  2. In pin.rb line no. 3,.remove the line acts_as_commentable which is not used by your gem commontator

Assuming that you have added acts_as_commontable to the Pin model,

In the pins/show.html.erb,

Replace

<%= commontator_thread(commontable) %>

With

<%= commontator_thread(@pin) %> 

As per the Commontator Usage Documentation,

In <%= commontator_thread(commontable) %>

commontable is an instance of a model that acts_as_commontable.

which in your case is @pin.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!