lorint / brick

Auto-generate models, views, controllers, and routes in a Rails app based on database structure
Other
269 stars 8 forks source link

NoMethodError when generating ActionText::RichText table #12

Open GALTdea opened 5 months ago

GALTdea commented 5 months ago

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.

lorint commented 5 months ago

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)

GALTdea commented 5 months ago

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 😅