Created
November 9, 2011 21:38
-
-
Save juanm55/1353153 to your computer and use it in GitHub Desktop.
How should I do this?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# I want to go from the session information (which contains the current logged in user_id) to his/her assigned EvaluationUser, down to his'/hers EvaluationCategories, down to the objectives associated to those, and finally the evidences related to each one of them.... | |
#the idea is being able to obtain and array of ob_evidences that the user has created.... but the following does not seem to work even though I have the associations which should make everything run swiftly,,,, | |
def index | |
@ob_evidences = EvaluationUser.where("user_id = ?", session[:user_id]).first.evaluation_categories.objectives.ob_evidences | |
end | |
#Am I missing something??? | |
#and the error I'm getting: | |
#NoMethodError in ObEvidencesController#index | |
#undefined method `objectives' for #<Class:0xbadc658> #### which is precisely the line that has the @ob_evidences described up there.... | |
#and yes, I have checked all the column associations and they are all well set... so... any ideas |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#here a pretty cascade of associations | |
class User < ActiveRecord::Base | |
has_many :evaluation_users | |
... | |
class EvaluationUser < ActiveRecord::Base | |
belongs_to :evaluation | |
belongs_to :user | |
has_many :evaluation_categories... | |
class EvaluationCategory < ActiveRecord::Base | |
belongs_to :evaluation_user | |
belongs_to :category | |
has_many :objectives | |
... | |
class Objective < ActiveRecord::Base | |
belongs_to :evaluation_category | |
has_many :ob_evidences | |
... | |
class ObEvidence < ActiveRecord::Base | |
mount_uploader :file, FileUploader | |
belongs_to :objective | |
... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment