I have a singular model, controller, view named "product". In my routes, I used activemodel so there is no pluralization.
resource :product, :controller => 'product'
When I use form_for:
<%= form_for( @product) do |f| %>
But I get the following error:
undefined method `products_path'
How do I fix this? It should be product_path.
I just found the solution. There are two methods to do this.
1) Add this to the Model file. model_name.instance_variable_set(:@route_key, 'product')
OR
2) = form_for @product, :url => product_path do |f|
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With