Giter Site home page Giter Site logo

fnando / ar-uuid Goto Github PK

View Code? Open in Web Editor NEW
46.0 46.0 4.0 77 KB

Override migration methods to support UUID columns without having to be explicit about it.

License: MIT License

Ruby 99.21% Shell 0.79%
activerecord postgres postgresql primary-key rails uuid

ar-uuid's People

Contributors

dependabot[bot] avatar fnando avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

ar-uuid's Issues

side effect in Rails 5: it breaks active_record.belongs_to_required_by_default = true

If you use ar-uuid to handle the uuid field typing for creating models and foreign key associations, a side effect is it breaks
Rails.application.config.active_record.belongs_to_required_by_default = true

In other words, for some reason the new Rails 5 default belongs_to validation (that ensures the child record contains the parent's id) is no longer run when an instance of the child is created or saved.

On the other hand, if you add the uuid typing manually instead of using the gem, the default belongs_to validation runs normally.

Unfortunately, as of Rails 5.0.1, which allows changing the default primary key to uuid without use of the ar-uuid gem, does not handle associations.

In our case we turn off the new Rails 5 belongs_to default validation, but I wanted to document this side-effect of the ar-uuid gem in case someone else is using it in Rails 5.

is it only needed when creating/running migrations (proposed ruby version issue workaround)

The dependency on ruby 2.1.0 or greater is unfortunate since 2.1 and 2.2 appear to be plagued with memory issues when running on Heroku.

For those of us still using Ruby 2.0 due to those memory issues, am I correct the gem is only used/needed in development, and only when creating migrations, and therefore it might be possible to temporarily upgrade ruby just when doing migrations but not when running the app? Eg, that there is no production behavior implemented in the gem?

I am hoping the following process might work (assuming the development machine uses rbenmv to manage both Ruby 2.0 and 2.1):

  1. when creating and running a migration:
    a) specify ruby 2.1+ in Gemfile and
    b) un-comment the ar-rails gen,
    c) then re-run bundle install
  2. create and run the migration
  3. re-edit gemfile to specify ruby 2.0 again as needed for production and comment out the ar-rails gem and run bundle install again

License

What license is this library made available under? Don't see one in the repository.

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.