Skip to content

Instantly share code, notes, and snippets.

@PeteMichaud
Created October 25, 2013 16:50
Show Gist options
  • Save PeteMichaud/7157891 to your computer and use it in GitHub Desktop.
Save PeteMichaud/7157891 to your computer and use it in GitHub Desktop.
class Widget < ActiveRecord::Base
include Thingable
end
class Thing < ActiveRecord::Base
belongs_to :widget
end
#thingable is namespaced to Widget
module Widget::Thingable
extend ActiveRecord::Concern
included do
has_many :things
end
end
#tries to load Thing namespaced to the same thing as the concern is namespaced to
> widget.things
uninitialized constant Widget::Thing
# forces rails not to use concern namespace
# this workaround works
module Widget::Thingable
extend ActiveRecord::Concern
included do
has_many :things, class_name: Thing
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment