Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Ruby Ruby Modules Store Inventory Using Modules Debugging Errors

Something is wrong with our self.included method and it isn't functioning correctly.

What is the answer to this question?

store.rb
module Inventory
  def self.included()
    klass.extend ClassMethods
  end

  module ClassMethods
    def create
    end
  end

  def stock_count
    @stock_count ||= 0
  end
end

class Shirt
  include Inventory
  attr_accessor :attributes

  def initialize(attributes)
    @attributes = attributes
  end
end

1 Answer

Shawn Wilson
seal-mask
.a{fill-rule:evenodd;}techdegree
Shawn Wilson
iOS Development Techdegree Student 7,049 Points

you need to reference klass in the self.include method like so

module Inventory
  def self.included(klass)
    klass.extend ClassMethods
  end

  module ClassMethods
    def create
    end
  end

  def stock_count
    @stock_count ||= 0
  end
end

class Shirt
  include Inventory
  attr_accessor :attributes

  def initialize(attributes)
    @attributes = attributes
  end
end