Comments (7)
I had to do something similarly kludgy with chromotype: I introduced the idea of a migration_safe_on_load that would ignore issues arising from tables not existing yet.
Do you think it's OK to "lie" and say that order isn't numeric just because the table doesn't exist? Would returning nil
be better? (Nothing will work otherwise, so we're limping in any event).
def order_is_numeric
return nil unless self.table_exists?
return false unless order_option
c = ct_class.columns_hash[order_option]
c && c.type == :integer
end
I think I like yours better, but I agree with your hate with &&
and unless
.
Happy to take your pull request! I'm finishing issue 31 right now, but if I can bang it out, I'll update this issue.
from closure_tree.
Technically it isn't numeric. I mean, it isn't there! I don't see a difference between nil and false so it's up to you on that one. I would say, if the method should return 'boolean' then have it do so.
I'll put something together and send it your way. I like the explicit returns. Easier to follow.
For what it's worth, I spent some time digging in Rails in the hopes of coming up with a workaround that we could just document and not have to do something janky. You can't disable them from instantiating although you can stop them from notifying. I even experimented with putting checks in application.rb
. It worked but made me want to take a shower.
# active record observers
config.active_record.observers = []
if ActiveRecord::Base.connected? && ActiveRecord::Base.connection.table_exists?(:tags)
config.active_record.observers << :tag_observer
end
from closure_tree.
To prevent unnecessary showering, why not use a "mixin" or "concern" module that you subsequently include in your Tag model? You don't have to do janky observers array mucking about then.
I'll add the twiddle in your initial comment now, in any event, though.
Thanks!
from closure_tree.
Ah, you're too fast. You coulda had a pull request. We could have had something together!
In the app where this came up I was able to just inline the observer callbacks right into the models, which worked for our application.
If time doesn't work out for you let me know if I can get that pull request done.
from closure_tree.
Oh, we have something, sir, we have something.
You are now the proud father of v3.6.7. Thanks for your help.
from closure_tree.
(BTW, I negated the unless, just in the hopes that it would make you happy)
from closure_tree.
💞
from closure_tree.
Related Issues (20)
- What should I do when my data volume is very large, more than 100 million? HOT 3
- easiest way to move element within list? HOT 3
- How can I migrate 3 million data to hierarchy table?
- N + 1 feedback
- Determinstic ordering using a second column if the value of the first is null
- `parent_id` as zero HOT 1
- Postgres 12 + Rails 6.1: RETURNING "id" issue HOT 1
- Hierarchy model inheritance breaks usage with STI and superclass validations HOT 1
- Regression in combination with paper_trail gem HOT 5
- Deferred hierachy rebuild
- Self-referential model breaks `#ancestors` method. HOT 1
- Children Not Destroyed on call.
- reason for with_ancestor method using map HOT 2
- Fix compound unique index for template in hierarchies_table HOT 4
- Dirty tracking lost when setting parent with numeric_order option HOT 1
- Could there be an option for with_ancestor to include ancestors?
- Loss of namespace when using Accessing Data methods HOT 1
- SystemStackError when updating fixtures HOT 1
- parallel_test fails HOT 2
- Usage with STI table HOT 1
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 closure_tree.