Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Defining Classes #105

Open
tomrossi7 opened this Issue · 0 comments

1 participant

@tomrossi7

I am working on upgrading my ActiveResource and integration with the latest Basecamp API. The association stuff looks great, but I noticed a problem where the class has to be defined before it is referenced in an association. Here is an example of what I mean.

class BasecampNext
  class Todolist < Resource
  end

  class Project < Resource
    has_many :todolists, class_name: 'basecamp_next/todolist'
  end
end

If I define the BasecampNext::Todolist class before the BasecampNext::Project class, everything works fine. If I definite it after, I get the following error when the file is loaded:

NameError: uninitialized constant BasecampNext::Todolist

This would create problems then if I tried to define a belongs_to :project association on BasecampNext::Todolist. I could define them all first and then define the associations, but I don't think that was intended.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.