Since I am a beginner, I would appreciate it if you could point out any mistakes. Posted for memorandum and output purposes.
new.html.slim
= form_with model: @review, local: true do |f|
.form-group
= f.label :purpose
= f.text_field :purpose, class:'form-control', id: 'review_purpose'
In, the following error "undefined method` reviews_path'" occurs. I haven't defined reviews_path in the first place.
ActionView::Template::Error (undefined method `reviews_path' for #<#<Class:0x00007fb7553f5138>:0x00007fb7553fc9b0>):
When I looked it up, the above "= form_with model: @review, local: true do |f|In the code of ", form_with model: @The review part is internally polymorphic_path(@review)It seems that the method is executed, and the execution result is reviews_Since it is a path, it seems that an error has occurred there.
Looking at the article, it seems that it will be solved if you specify where to fly firmly with form_for as follows.
new.html.slim
= form_for @review,:url => {:action => :create} do |f|
Regarding this, I am creating a path corresponding to the new action of the controller being executed from the url option, and since this path exists, it does not seem to cause an error.
Recommended Posts