Search code examples
ruby-on-railsrubyrails-admin

How to stop Rails Admin from truncating a field?


I have a rails_admin model config as follows:

rails_admin do
  list do
    field :summary
  end
end

And summary is a custom method in my model that basically just returns a very long text:

def summary
  first_name + last_name + ':\n' + bio 
end

What I'm having trouble with is that this text gets truncated in the list view, and my \n newline characters doesn't render into actual new lines.

I basically want to print the entire long text, without truncation in the list view, and have line breaks that I defined. Help is appreciated.


Solution

  • could you try to do it in a different way like this: change the new line \n with a line brake <br> then return it as HTML safe.

    def summary
      (first_name + last_name + '<br>' + bio).html_safe
    end