0

I am writing a class method to find certain data in my database however I am getting a NoMethodError: undefined method error. I am using Datamapper instead of ActiveRecord. Here is my error output:

NoMethodError: undefined method `get_courses_starting_in' for Course:Class
    from /Users/hugo/.rvm/gems/ruby-1.9.2-p318/gems/dm-ar-finders-1.2.0/lib/dm-ar-finders.rb:155:in `method_missing_with_find_by'
    from /Users/hugo/Web Development/Rails/connectedtrips/lib/ct_gems/dm-core-1.2.0/lib/dm-core/model/relationship.rb:372:in `method_missing'
    from /Users/hugo/Web Development/Rails/connectedtrips/lib/ct_gems/dm-core-1.2.0/lib/dm-core/model/property.rb:249:in `method_missing'
    from (irb):24
    from /Users/hugo/.rvm/gems/ruby-1.9.2-p318/gems/railties-3.2.3/lib/rails/commands/console.rb:47:in `start'
    from /Users/hugo/.rvm/gems/ruby-1.9.2-p318/gems/railties-3.2.3/lib/rails/commands/console.rb:8:in `start'
    from /Users/hugo/.rvm/gems/ruby-1.9.2-p318/gems/railties-3.2.3/lib/rails/commands.rb:41:in `<top (required)>'
    from script/rails:6:in `require'
    from script/rails:6:in `<main>'

And here is my class method:

def self.get_courses_starting_in
    courses = []
    Course.all.each{ |course| courses << course if course.days_till_course_starts == 7}
    return courses
  end

I hope someone can help. Thanks.

Hugs
  • 915
  • 4
  • 20
  • 47

1 Answers1

0

Have you write the code after starting the console? Restart console and check again.

Echilon
  • 10,064
  • 33
  • 131
  • 217
Salil
  • 46,566
  • 21
  • 122
  • 156