activeadmin / inherited_resources

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

duplicate belongs_to calls break routing

seanlinsley opened this issue · comments

As I mentioned in activeadmin/activeadmin#2386 (comment), this code breaks:

ProjectsController < InheritedResources::Base
  belongs_to :user
  belongs_to :user
end
ProjectsController.parents_symbols # => [:user, :user]
ProjectsController.new.send :new_resource_path
# NoMethodError: undefined method `new_user_user_project_path'

The solution seems to be to change this line to something like this:

parents_symbols << symbol unless parents_symbols.include? symbol

Either that, or change parents_symbols to be a Set instead of an Array: http://www.ruby-doc.org/stdlib-2.0/libdoc/set/rdoc/Set.html

Hmm, seems I didn't read the docs