brick icon indicating copy to clipboard operation
brick copied to clipboard

NoMethodError when generating ActionText::RichText table

Open GALTdea opened this issue 1 year ago • 2 comments

Hi Lorint,

Love this gem! I'm testing this gem with a database that contains a rich_text table, and I am getting a has_many_attached' for ActionText::RichText:Class (NoMethodError) when running the install generator.

Seems like the RichText class is not being loaded?

I'm not sure if am missing something, but I'll keep looking into it tomorrow.

ps. I'm not sure if you remember me, but I was in your Santa Monica class back in the day.

GALTdea avatar Jan 26 '24 03:01 GALTdea

not sure if you remember me, but I was in your Santa Monica class back in the day

Heya Gustavo! Long time and cool to catch back around with ya.

I've been looking into this exact issue in one of the apps that I test Brick against. It seems that if you have both Ransack and also ActionText::RichText that this can crop up. Have been considering adding a patch in Brick to accommodate this. Would look something like this:

ActiveSupport.on_load(:action_text_rich_text) do
  class ActionText::RichText < ActionText::Record
    def self.ransackable_attributes(auth_object = nil)
      authorizable_ransackable_attributes
    end
  end
end

Put that at the end of your application.rb, and perhaps it will jump to life! (Comes courtesy of This SO article)

lorint avatar Jan 26 '24 13:01 lorint

Interesting, I'll give this a try and report back!

Don't have much experience with gems, but I'm 'prying' my way through the gem to learn a bit more about how it works. I think this gem has a TON of potential and, would love to help in whatever I can!

Also, I don't know if you already have this in mind, but what do you think about the idea of adding a library of potential databases and table schemas so that it wouldn't need to take the info from an existing database? (Potentially adding some AI functionality). So, in the nice database GUI you have, you could add an option for "databases library." Hope that makes sense 😅

GALTdea avatar Jan 26 '24 16:01 GALTdea