Defining Classes #105

Closed
tomrossi7 opened this Issue Oct 17, 2013 · 1 comment

Comments

Projects
None yet
3 participants

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.

rails-bot bot added the stale label May 5, 2017

rails-bot bot commented May 5, 2017

This issue has been automatically marked as stale because it has not been commented on for at least three months.
The resources of the Rails team are limited, and so we are asking for your help.

If it is an issue and you can still reproduce this error on the master branch,
please reply with all of the information you have about it in order to keep the issue open.

If it is a pull request and you are still interested on having it merged please make sure it can be merged clearly.

Thank you for all your contributions.

Owner

rafaelfranca commented May 5, 2017

This issue has been automatically marked as stale because it has not been commented on for at least three months.

The resources of the Rails team are limited, and so we are asking for your help.

If it is an issue and you can still reproduce this error on the master branch, please reply with all of the information you have about it in order to keep the issue open.

If it is a pull request and you are still interested on having it merged please make sure it can be merged clearly.

Thank you for all your contributions.

rails-bot bot closed this May 13, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment