MotionModel icon indicating copy to clipboard operation
MotionModel copied to clipboard

Module support on relations

Open jwright opened this issue 11 years ago • 2 comments

Namespacing your models with modules is not currently supported.

For example:

module GIJoe
  class Enemy
  end
end

module GIJoe
  class SnakeEyes
    has_many :enemies
  end
end

This results in an error with an undefined constant enemy.

Suggested fix

The column class should not assume Object.const_get and can use the classes module or loop through the modules specified in :as and :joined_class_name using the camelize method of specifying modules (e.g. gi_joe/enemy)

module GIJoe
  class Enemy
  end
end

class SnakeEyes
  has_many :enemies, joined_class_name: 'gijoe/enemy'
end

jwright avatar Aug 23 '13 19:08 jwright

Can you get a PR together for this?

sxross avatar Aug 24 '13 03:08 sxross

Yep.

jwright avatar Aug 25 '13 04:08 jwright