Rather than using form_with scope:
try this instead.
In your controller's new
action you need to create a new unsaved record. I have no idea what your model is called, so I'm guessing based on your controller name:
def new
@mynew = Mynew.new
end
Next, in your view, do the form like this:
<%= form_with model: @mynew, local: true do |form| %>
And it'll handle the paths etc for you.
However, I suspect your model probably isn't called Mynew
, in which case you'd have to specify the url.
Assuming your model is actually called something like Article
, I'd advise you to also name your controller ArticlesController
. If you want the actual URL to be different you can configure that in your routes
file ... but creating/updating/deleting an Article
should be handled by the ArticlesController
, regardless of what URL the users see.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…