Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change #associations to #extensions #16

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

iwarshak
Copy link

@iwarshak iwarshak commented Apr 7, 2011

Mongoid (at least 2.0.1) does not return a classes association with the #associations method. It does with the #extension method.

I am not exactly sure why, because it seems that in macros.rb (in mongoid) the method is aliased, but for whatever reason it wasn't working.

I simply changed the method from #associations to #extensions.

@martinciu
Copy link

+1

1 similar comment
@Frost
Copy link

Frost commented May 4, 2011

+1

@ahamid
Copy link

ahamid commented May 23, 2011

Until this gets applied, I found dropping this into your blueprints.rb works on the machinist2 branch:

# fix Mongoid association/relation support
# https://github.com/nmerouze/machinist_mongo/pull/16
Machinist::Mongoid::Lathe.class_eval do
  def make_association(attribute, args) #:nodoc:
    association = @klass.relations[attribute.to_s]
    if association
      association.klass.make(*args)
    else
      raise_argument_error(attribute)
    end
  end
end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants