I found a simple solution: First, I removed the shallow
in model3
.By opening the helper class and adding a method_missing definition, this was easily possible:
def method_missing(method, *args, &block)
super unless /model3s?_(path|url|uri)$/ =~ method.to_s
sub_string = nil
if args.first.is_a? Model1
substring = 'model1'
elsif args.first.is_a? Model2
substring = 'model2'
end
self.send(method.to_s.gsub('model3', "#{substring}_model3"), *args, &block)
end
It would be possible to define each of those by themselves (new_model3_path, model3_path, edit_model3_path, model3s_path) but I found this one more concise.