我得到了配置Cart和CartItem(belongs_to :cart)模型.
我想做的是打电话polymorphic_path([@cart, @cart_item])让它使用cart_item_path,而不是cart_cart_item_path.
我知道我可以更改的路线生成的URL /carts/:id/items/:id,但是这不是我感兴趣的.此外,重命名CartItem到Item是不是一种选择.我只想cart_item_path在整个应用程序中使用方法.
提前感谢任何提示!
只是为了表明我的观点:
>> app.polymorphic_path([cart, cart_item])
NoMethodError: undefined method `cart_cart_item_path' for #<ActionDispatch::Integration::Session:0x007fb543e19858>
Run Code Online (Sandbox Code Playgroud)
所以,为了重复我的问题,我能做些什么polymorphic_path([cart,cart.item])来寻找cart_item_path而不是cart_cart_item_path?