undefined method `** _ path'error

Purpose of the article

Since I am a beginner, I would appreciate it if you could point out any mistakes. Posted for memorandum and output purposes.

error contents

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.

approach

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

undefined method `** _ path'error
Method
NoMethodError: undefined method `setup'for Devise: Module
[Ruby] undefined method `dark?'occurs in rqr_code
Java method
to_i method
java (method)
getRequestDispatcher () method
merge method
Map method
include method
initialize method
puts method
Java method
Class method
save! method
getParameter method
RSpec error resolution undefined method `feature'for RSpec: Module
private method
What to do when undefined method ʻuser_signed_in?'
rails method
[Java] method
[Ruby on Rails] NoMethodError undefined method `devise_for'error resolution
Rails error undefined method ʻimage_name'for nil: NilClass handling