Bodacious/blogit

check_comments_config when not active record

Closed this issue · 3 comments

I have blogit successfully working in all respects. I have turned on disqus comments in config/initializers/blogit.rb

Everything works fine, except when using rails_admin to view/add/edit a post I get the following error:

Posts only allow active record comments (check blogit configuration)

This is raised by the post model in check_comments_config

def check_comments_config
  raise RuntimeError.new("Posts only allow active record comments (check blogit configuration)") unless Blogit.configuration.include_comments == :active_record
end

All is well if I change the 'unless' to an 'if' but am hesitant to so without understanding the implications.

As I read this, what's happening here is Post#comments is only to be used with active record comments.

The check_comments_config method is ensuring that, if comments is called, it'll raise an exception unless blogit's include comments is set to :active_record

So I believe the code is fine.

If you're using disqus, then you shouldn't be calling @post.comments from within your app - could that be the case?

Thanks for confirming my hopes. My issue is with RailsAdmin...I just need to either hide the model altogether or tell it not use the comments field.

Good luck 😄