Git Product home page Git Product logo

Comments (7)

mceachen avatar mceachen commented on August 26, 2024

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.

elskwid avatar elskwid commented on August 26, 2024

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.

mceachen avatar mceachen commented on August 26, 2024

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.

elskwid avatar elskwid commented on August 26, 2024

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.

mceachen avatar mceachen commented on August 26, 2024

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.

mceachen avatar mceachen commented on August 26, 2024

(BTW, I negated the unless, just in the hopes that it would make you happy)

from closure_tree.

elskwid avatar elskwid commented on August 26, 2024

💞

from closure_tree.

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.