-1

I have called my function in gems/plugins/account_reports/lib/account_reports/grade_reports.rb file. Now I want to use the same function in lib/reporting/enrollment_details_progress_report.rb file. For that I added require '/gems/plugins/account_reports/lib/account_reports/grade_reports' in lib/reporting/enrollment_details_progress_report.rb file at the top and called that function by using AccountReports::GradeReports.fetch_student_course_completion_date(rec["course_id"], rec["term_id"]) but I am getting the error 'undefined methodfetch_student_course_completion_date'' for AccountReports::GradeReports:Class'`.

Also tried load "gems/plugins/account_reports/lib/account_reports/grade_reports.rb" but still I am getting the error.

Neha
  • 305
  • 5
  • 23

1 Answers1

0

Are you sure, that class have fetch_student_course_completion_date as a class method?

you can try require_relative. What is the difference between require_relative and require in Ruby?

Community
  • 1
  • 1
Lukas Baliak
  • 2,849
  • 2
  • 23
  • 26
  • I tried require_relative '/gems/plugins/account_reports/lib/account_reports/grade_reports.rb' but still getting the error: cannot load such file -- /gems/plugins/account_reports/lib/account_reports/grade_reports.rb – Neha Jan 08 '16 at 11:01
  • @Sneha Ok, use require. And Are you sure, that class have fetch_student_course_completion_date as a class method? – Lukas Baliak Jan 08 '16 at 11:03
  • Added self in fetch_student_course_completion_date method. Its working now. Thanks. – Neha Jan 08 '16 at 14:04
  • @Sneha Ok, I like to help ;) – Lukas Baliak Jan 08 '16 at 14:07