Git Product home page Git Product logo

active_data's People

Contributors

barthez avatar bioform avatar dabrorius avatar dnnx avatar epecherkin avatar jaimerson avatar larkinscott avatar lest avatar mpospelov avatar ojab avatar pawlik avatar pyromaniac avatar rewritten avatar shurikp avatar tei avatar tonkpils avatar undr avatar zorbash 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  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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

active_data's Issues

Support preloading of associations

Consider a model with references inside embedded collection:

class Example
  include ActiveData::Model

  embeds_many :users do
    references_one :user
  end
end

accessing users causes 1 model query per each element of the users collection.

Suggestion

Add the preload method to eagerly preload selected associations to avoid N+1's queries.

Documentation: Compare with Virtus?

I've typically used Virtus for form objects and mimicking an ActiveModel API in general. On the surface, the two libraries appear to have similar goals.

I recommend adding a brief note to the readme that compares this library to Virtus. It would help casual passersby, like me, understand why they should spend time investigating. Of course, I'm assuming you want more Internet randos using your library and that you made specific design decisions to be different from Virtus. Neither may be true. 😛

Anyway, code looks clean from my brief skimming, but I don't really have any friction points with Virtus motivating me to seek out new solutions in this area. Cheers.

NoMethodError: undefined method `each' for nil:NilClass

Not always, but sometimes I can see in my Airbrake

https://www.dropbox.com/s/mh5zvnl4zcyjs8o/Screenshot%202015-11-16%2022.24.24.png?dl=0

Params: { "action": "index", "controller": "search" }

Code:
https://www.dropbox.com/s/i3g0yqw79tt588g/Screenshot%202015-11-16%2022.25.23.png?dl=0

Don't know how to reproduce. I can add something like "obj || {}" and make PR, but I think issue is different

If you will tell me how to reproduce and suggest dirrectio how to fix - I can make PR

after_initialize not defined?

I'm trying to run some method after initialize and it's giving me the following:

NoMethodError at /api/v1/search
=====================================

> undefined method `after_initialize' for Search:Class

According to this, I should be able to do the following:

class Search
  include ActiveData::Model

  after_initialize :define_qualifiers
  ...

Release new version?

I've been tracking master for a bit since there've been 200+ commits since 0.3. Could you cut a new version to rubygems? Thanks!

DEPRECATION WARNING: alias_method_chain is deprecated.

In Rails 5, Ruby 2.3 @ /lib/active_data/active_record/nested_attributes.rb:7

Please, use Module#prepend instead. From module, you can access the original method using super. (called from block in <module:NestedAttributes> at /usr/local/bundle/bundler/gems/active_data-949dc14bb8cc/lib/active_data/active_record/nested_attributes.rb:7)

Uninitialized Constant breaking Rails console

After updating to ActiveData 0.3.0 I am now receiving the following error when trying to run rails c:

/vendor/bundle/ruby/2.1.0/bundler/gems/active_data-10a2aef9bd81/lib/active_data/model/primary.rb:6:in '<module:Primary>': uninitialized constant ActiveData::UUID (NameError)

Incompatible with ActiveModel 6.1

The ActiveModel::Errors class has changed, keeping most of the high level API compatible, but some of the underlying implementation are not working anymore.

The class ActiveData::Model::Validations::NestedValidator is not compatible with the new implementation, it should be something on the lines of:

def self.validate_nested(record, name, value)
  if value.is_a?(Enumerable)
    value.each.with_index do |object, i|
      if yield(object)
        object.errors.each do |error|
          record.errors.import(error, attribute: "#{name}.#{i}.#{error.attribute}")
        end
      end
    end
  elsif value && yield(value)
    value.errors.each do |error|
      record.errors.import(error, attribute: "#{name}.#{error.attribute}")
    end
  end
end

but of course this only works with the new errors interface… so maybe a version check? I haven't been able to find a version-independent way to achieve it.

alias_method_chain is being deprecated in Rails 5.0

When testing my app against the latest Rails 5.0 beta, I noticed a deprecation warning being called within active_data:

DEPRECATION WARNING: alias_method_chain is deprecated. Please, use Module#prepend instead. From module, you can access the original method using super. (called from block in module:Callbacks at /lib/active_data/model/callbacks.rb:48)

I'm not sure that I have the dev chops to open a pull request to fix this, but thought I should bring it to your attention in the event that you were not aware. Thanks!

Default values was calculated each time as we called read_attribute

class MyClass
  include ActiveData::Model

  attribute :id, type: String, default: proc{SecureRandom.uuid}
end
my_class = MyClass.new
pp my_class.id
pp my_class.id
"f50d373d-16b8-436a-a36c-d8c6903994d8"
"1fca043d-39f1-4e9f-9f01-87295e24ae48"

I think, id has to be same each time as we call read_attribute on the same object. What do you think?

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.