Giter Site home page Giter Site logo

Comments (7)

baldwindavid avatar baldwindavid commented on August 14, 2024

Hello:
I also just added support for "belongs_to" within the ActiveHash class itself.

I know that in a separate message there were concerns about this being dependent on Rails. However, this is not so much Railsy as it is ActiveRecord-ish...which ActiveHash is trying to mimic.

This gist http://gist.github.com/164937 (which includes the belongs_to method) is an example Sinatra app and the associations seem to work just fine. The common Rails methods (constantize, foreign_key, etc.) used within the has_many and belongs_to are available via active_support, which is already a dependency of ActiveHash.

Both ActiveHash/ActiveHash and ActiveHash/ActiveRecord associations should work outside of Rails. Of course, the methods would not work with DataMapper or Sequel, but AR is what is being mimicked here anyway. Does that make sense or are there use cases where this would be problematic?

from active_hash.

zilkey avatar zilkey commented on August 14, 2024

Awesome! I've just added it. Sorry for the long delay...

from active_hash.

contentfree avatar contentfree commented on August 14, 2024

Looks like this was closed, but it appears that ActiveHash (and ActiveYaml) are still missing support for has_many (at least it seems to be the case between ActiveHash classes)

from active_hash.

zilkey avatar zilkey commented on August 14, 2024

Associations are in the Associations module (https://github.com/zilkey/active_hash/blob/master/lib/associations/associations.rb) so you have to include that. If you want them in all ActiveHash objects, you can do something like this in an initializer:

ActiveRecord::Base.send(:include, ActiveHash::Associations)

Does that cover it, or are we missing something else?

from active_hash.

contentfree avatar contentfree commented on August 14, 2024

Ah... I must've missed that in the docs. Will check it out.

from active_hash.

zilkey avatar zilkey commented on August 14, 2024

Come to think of it, I'm not sure if it's in the docs. I'll add that soon.

On Aug 7, 2013, at 11:44 PM, Dave Myron [email protected] wrote:

Ah... I must've missed that in the docs. Will check it out.

Reply to this email directly or view it on GitHub.

from active_hash.

contentfree avatar contentfree commented on August 14, 2024

I think it is. (Unless you just added it tonight!)

from active_hash.

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.