Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

has_many :through with acts as list #95

Closed
ldonnet opened this issue Nov 12, 2013 · 2 comments
Closed

has_many :through with acts as list #95

ldonnet opened this issue Nov 12, 2013 · 2 comments

Comments

@ldonnet
Copy link

ldonnet commented Nov 12, 2013

I want to use your acts as list gem with these models :

module ActiveRoad
  class PhysicalRoad < ActiveRoad::Base
    has_many :physical_road_junctions
    has_many :junctions, :through => :physical_road_junctions, :dependent => :destroy, :uniq => true
  end
end
module ActiveRoad
  class PhysicalRoadJunction < ActiveRoad::Base
    attr_accessible :position  

    belongs_to :physical_road
    belongs_to :junction

    acts_as_list :scope => :physical_road
  end
end
module ActiveRoad
  class Junction < ActiveRoad::Base
    has_many :physical_road_junctions
    has_many :physical_roads, :through => :physical_road_junctions
  end
end

But when I use the scope of acts_as_list an exception is raised :

ActiveRoad::Junction junction connected to physical roads #physical_roads should be addable
     Failure/Error: subject.physical_roads << new_road
     NameError:
       uninitialized constant ActiveRecord::NamedScope
     # (eval):25:in `scope_condition'
     # ./spec/models/active_road/junction_spec.rb:18:in `block (4 levels) in <top (required)>'

Should we use this gem in a special way with has_many :through relations?

Best Regards
Luc Donnet

@swanandp
Copy link
Contributor

swanandp commented Dec 7, 2013

This might be something to do with the namespacing of classes under the ActiveRoad module. I followed an exact same setup, without the module, and it worked for me.

@ldonnet
Copy link
Author

ldonnet commented Sep 22, 2014

I dig deeper into this problem and acts_as_list is not the guilty. It's an other plugin I use postgis_adapter. Sorry to have disturbed you with this problem and thanks for your help.

@ldonnet ldonnet closed this as completed Sep 22, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants