Comments (3)
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.
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.
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)
- Dependabot can't resolve your Ruby dependency files
- Dependabot can't resolve your Ruby dependency files
- Dependabot can't resolve your Ruby dependency files
- Dependabot can't resolve your Ruby dependency files
- Dependabot can't resolve your Ruby dependency files
- Dependabot can't resolve your Ruby dependency files
- Dependabot can't resolve your Ruby dependency files
- Dependabot can't resolve your Ruby dependency files
- Can not use with library 'activestorage' HOT 3
- Incorrectly marks ActiveRecord accessors as being non-nil
- NoMethodError error on enum with `_default` option set
- rbs_rails doesn't generate definitions for ActiveRecord DSLs within module HOT 1
- generated rbs for activerecord models does not respect `serialize`
- How to skip a method from gems? HOT 2
- How to fix `Cannot find compatible overloading of method`?
- Unexpected token for method name HOT 2
- Generator breaks on using composite primary key. HOT 3
- RBS Rails writes blanks HOT 3
- How to fix `NameError: uninitialized constant Star::Notification` HOT 8
- Output absolute type name
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rbs_rails.