'Ruby Active record model, How to return selected attributes and override one attribute

I have model called UserUrl inside this i have enum:

enum category: { custom_url: "custom_url", email_share: "share_url" }

has_rich_text :email_content

When ever i have called the users_url.share_url will give activerecord relation object which is correct but for email_content i want email_content.body&.to_trix_html.

So i need to create a custom method in UsersUrl model called

def self.custom_response
  select(:id, :name)
end

but i want email_content as a email_content.body.to_trix_html.

What is the good way to do it?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source