Skip to main content

@mentions for Users with ActionText in Rails 6 Discussion

General • Asked by Chris Oliver

This is a great video.

Is it possible to remove jQuery if you are using Bootstrap 4? I know it's a dependency but maybe if you are not using all aspects of Bootstrap you can remove it.

Anyway, removing jQuery is a good way to remove 250kb (30kb gzipped) from your website's download which is not bad at all.

The next major version of Bootstrap will be without jQuery


Is it possible to change the default render for other one?

When Trix render I would like to use a different partial. For example _user_trix.html.erb so I can include some special content.

Hi Franklin,

I believe you can define a #to_trix_content_attachment_partial_path on your User model, e.g.

class User < ApplicationRecord
    include ActionText::Attachable
    ...
    def to_trix_content_attachment_partial_path
        'users/user_trix'
    end
end

Hey Chris,

Awesome episode as usual! Few quick questions:

  1. Since ActionText is storing a global_id reference to records in order to display the updated partial at render time, does that mean it's making a separate DB query to retrieve each of those records? For instance, if I @mention 10 separate users, will it make 10 separate calls? Especially if I'm creating a commenting system that allows @mentions, and there could be 10-20 comments, each with several @mentions, etc...
  2. I notice you used Zurb Tribute for the @mention library; you've done an episode before using AtJs, any benefits to Tribute over AtJs, or just preference?

I really do like the concept of storing a reference to the partial instead of the hard-coded HTML. I'm actually in a situation where I stored the HTML snippets in the text itself and now want to change it, but am struggling with how to do that using the Froala editor. I'll eventually migrate to ActionText in a few months after Rails 6 has been vetted in the wild.

Always appreciate your timely and very applicable videos!


Great episode. How Trix works has become a little bit clearer. Thanks!


any way to implement @mentions if I am using rails strictly for an API?


Login or Create An Account to join the conversation.

Subscribe to the newsletter

Join 20,000+ developers who get early access to new screencasts, articles, guides, updates, and more.

    By clicking this button, you agree to the GoRails Terms of Service and Privacy Policy.

    More of a social being? We're also on Twitter and YouTube.