I got a configuration with Cart
and CartItem
( belongs_to :cart
).
I want to do this to call polymorphic_path([@cart, @cart_item])
so that it uses cart_item_path
instead of cart_cart_item_path
.
I know that I can change the url generated by the route to /carts/:id/items/:id
, but this is not what interests me. In addition, renaming CartItem
to Item
not an option. I just want to use the cart_item_path
method throughout the application.
Thanks in advance for any feedback!
Just to understand my point:
>> app.polymorphic_path([cart, cart_item]) NoMethodError: undefined method `cart_cart_item_path' for #<ActionDispatch::Integration::Session:0x007fb543e19858>
So, to repeat my question, what can I do to make polymorphic_path([cart,cart.item])
look for cart_item_path
and not cart_cart_item_path
?
source share