Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Singular Model,Controller, Form_for reference

I have a singular model, controller, view named "product". In my routes, I used activemodel so there is no pluralization.

Routes:

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.

like image 435
user2012677 Avatar asked Mar 04 '26 20:03

user2012677


1 Answers

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|

like image 179
user2012677 Avatar answered Mar 06 '26 11:03

user2012677