Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # stick this method in project.rb
- def self.list_of_person_ids_who_are_participants_and_belong_to_an_activity(project_id)
- joins = "JOIN activities ON activities.project_id = projects.id "
- joins << "JOIN activity_executions ON activity_executions.activity_id = activities.id"
- conditions = ["projects.id = ? ", project_id]
- find( :all,
- :select => 'activity_executions.person_id',
- :conditions => conditions,
- :joins => joins)
- end
- # go to ruby script/console and perform following operation
- >> Project.list_of_person_ids_who_are_participants_and_belong_to_an_activity(1)
- # I get following error from auto_escape
- >> Project.list_of_person_ids_who_are_participants_and_belong_to_an_activity(1)
- Project Load (0.000929) SELECT activity_executions.person_id FROM `projects` JOIN activities ON activities.project_id = projects.id JOIN activity_executions ON activity_executions.activity_id = activities.id WHERE (projects.id = 1 )
- Project Columns (0.003555) SHOW FIELDS FROM `projects`
- NoMethodError: You have a nil object when you didn't expect it!
- The error occurred while evaluating nil.text?
- from /Users/nkumar/work/community_service/vendor/plugins/auto_escape/lib/auto_escape.rb:57:in `after_find'
- from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/set.rb:231:in `delete_if'
- from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/set.rb:231:in `delete_if'
- from /Users/nkumar/work/community_service/vendor/plugins/auto_escape/lib/auto_escape.rb:57:in `after_find'
- from /Library/Ruby/Gems/1.8/gems/activerecord-2.1.0/lib/active_record/callbacks.rb:301:in `send'
- from /Library/Ruby/Gems/1.8/gems/activerecord-2.1.0/lib/active_record/callbacks.rb:301:in `callback'
- from /Library/Ruby/Gems/1.8/gems/activerecord-2.1.0/lib/active_record/base.rb:1446:in `send'
- from /Library/Ruby/Gems/1.8/gems/activerecord-2.1.0/lib/active_record/base.rb:1446:in `instantiate'
- from /Library/Ruby/Gems/1.8/gems/activerecord-2.1.0/lib/active_record/base.rb:582:in `find_by_sql'
- from /Library/Ruby/Gems/1.8/gems/activerecord-2.1.0/lib/active_record/base.rb:582:in `collect!'
- from /Library/Ruby/Gems/1.8/gems/activerecord-2.1.0/lib/active_record/base.rb:582:in `find_by_sql'
- from /Library/Ruby/Gems/1.8/gems/activerecord-2.1.0/lib/active_record/base.rb:1341:in `find_every'
- from /Library/Ruby/Gems/1.8/gems/activerecord-2.1.0/lib/active_record/base.rb:536:in `find'
- from /Users/nkumar/work/community_service/app/models/project.rb:321:in `list_of_person_ids_who_are_participants_and_belong_to_an_activity'
- from (irb):8
Add Comment
Please, Sign In to add comment