Giter Site home page Giter Site logo

Comments (3)

hawkcookie avatar hawkcookie commented on August 10, 2024

@pocke

I found ignore_model_if attribute. So, I defined rbs.rake as below.

require 'rbs_rails/rake_task'

RbsRails::RakeTask.new do |rbs|
  rbs.ignore_model_if = ->(model) {
    [
      ActionText::RichText,
      ActionMailbox::InboundEmail,
      ActiveStorage::Blob,
      ActiveStorage::VariantRecord,
      ActiveStorage::Attachment
    ].include?(model)
  }
end

Do we have to initialize RbsRails::RakeTask as above, when we want to ignore these models which rails gives by default but we do not necessarily use.

irb(main):002:0> ActiveRecord::Base.descendants
=> [
ApplicationRecord(abstract), 
ActionText::Record(abstract),
ActionText::RichText (call 'ActionText::RichText.connection' to establish a connection),
ActionMailbox::Record(abstract),
ActionMailbox::InboundEmail (call 'ActionMailbox::InboundEmail.connection' to establish a connection), 
ActiveStorage::Record(abstract),
ActiveStorage::Blob (call 'ActiveStorage::Blob.connection' to establish a connection),
ActiveStorage::VariantRecord (call 'ActiveStorage::VariantRecord.connection' to establish a connection), 
ActiveStorage::Attachment (call 'ActiveStorage::Attachment.connection' to establish a connection)
]

For example, is it bad to change like this?

diff --git a/lib/rbs_rails/rake_task.rb b/lib/rbs_rails/rake_task.rb
index 4c56101..ff3c8c5 100644
--- a/lib/rbs_rails/rake_task.rb
+++ b/lib/rbs_rails/rake_task.rb
@@ -3,13 +3,13 @@ require 'rake/tasklib'
 
 module RbsRails
   class RakeTask < Rake::TaskLib
-    attr_accessor :ignore_model_if, :name
+    attr_accessor :name, :ignore_models
 
-    def initialize(name = :rbs_rails, &block)
+    def initialize(name = :rbs_rails, ignore_models: [], &block)
       super()
 
       @name = name
-
+      @ignore_models = ignore_models
       block.call(self) if block
 
       def_copy_signature_files
@@ -50,7 +50,7 @@ module RbsRails
         # HACK: for steep
         (_ = ::ActiveRecord::Base).descendants.each do |klass|
           next if klass.abstract_class?
-          next if ignore_model_if&.call(klass)
+          next if ignore_models.include?(klass)

from rbs_rails.

pocke avatar pocke commented on August 10, 2024

Could not find table 'action_text_rich_texts' ActiveRecord::StatementInvalid Error happens in new simple rails project without model.

This is o confirm, what is the meaning of "new simple rails project"? I guess it means the project is initialized by rails new command and it doesn't include any changes without RBS Rails, right?

For example, is it bad to change like this?

I'm not sure why do you need this change.

Doesn't the rake task definition that using ignore_model_if work well?
I expect the rake task ignores the models, so please tell me if it doesn't work well.

from rbs_rails.

pocke avatar pocke commented on August 10, 2024

I've released RBS v0.8.1. It ignores AR classes if the class doesn't have a table in DB.
I think it solves this issue without the configuration. So I closed this issue.

If you have any opinion about the interface of the rake task, feel free to commit to this issue or open a new issue.

Thanks.

from rbs_rails.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.