Joe Guerra Joe Guerra - 1 month ago 7
Ruby Question

Commontator gem username

I'm using the Commontator gem and it's working fine. Unfortunately, the logged in user who adds a comment shows up as Anonymous. How do I use the username in my user model for Commontator?

Thanks,
Joe

Answer

From https://github.com/lml/commontator/wiki/Custom-username-on-comments :

If you are creating a comment and see "Anonymous" as the commentor and would like to customize what is displayed there ie. "Frank" or "example@gmail.com" you can customize that by going into the config/initializers/commontator.rb file and changing this line:

config.user_name_proc = lambda { |user| I18n.t('commontator.anonymous') }

For instance, if you have a 'full_name' method, you could change the above to:

config.user_name_proc = lambda { |user| user.full_name }
Comments