Hello,
I am having some difficulties with ActiveRecord.
What I want to do is to get a collection of SubjectGroups for using
with option_groups_from_collection_for_select
My Code:
========================================
class Subject < ActiveRecord::Base
has_and_belongs_to_many :users
belongs_to :subject_group
end
class SubjectGroup < ActiveRecord::Base
has_many :subjects
end
@subjects= Subject.find(:all, :include => :subject_group)
@groups= SubjectGroup.find(:all, :include => :subjects)
The first find instruction runs just fine, the second gives me the
following error:
You have a nil object when you didn’t expect it!, The error occurred
while evaluating nil.loaded
I was expecting a SubjectGroup collection with all Subjects associated.
In both cases I saw the generated queries through logs and returns the
same query result.
Thank you for your attention,
Paulo A.
Paulo A. wrote:
You have a nil object when you didn’t expect it!, The error occurred
while evaluating nil.loaded
Is that the entire code of your SubjectGroup model, or have you also
defined your own “subjects” method within it?
–
We develop, watch us RoR, in numbers too big to ignore.
On 7/15/06, Mark Reginald J. [email protected] wrote:
following error:
You have a nil object when you didn’t expect it!, The error occurred
while evaluating nil.loaded
Is that the entire code of your SubjectGroup model, or have you also
defined your own “subjects” method within it?
The idia is to add my own methods for
option_groups_from_collection_for_select, however I am not able to
make this search. if I remove :include => :subjects it just works.
In the IRC channel someone told me that I have a Subject with a
subject_group_id that refers to a subject_group that doesnt exist, but
I already verified that.
Paulo A.
On 7/15/06, Mark Reginald J. [email protected] wrote:
following error:
You have a nil object when you didn’t expect it!, The error occurred
while evaluating nil.loaded
Is that the entire code of your SubjectGroup model, or have you also
defined your own “subjects” method within it?
Oh sorry, I did not answer to your question. Is the entire code, no
methods added yet.
Paulo A.
Oh sorry, I did not answer to your question. Is the entire code, no
methods added yet.
Oh god, I think I need to sleep in fact I had two member functions,
that was the problem.
Paulo A…