This question is to understand the strange fact that for one situation it is necessary to informe the path, in form_for, and in another time it is not necessary, but stil works. Before using partials the form_for were diferent from edit and new forms. *
New Article
<%= form_for :article, url: articles_path do |f| %> and…Editing Article
<%= form_for :article, url: article_path(@article), method: :patch do |f| %>* It's dificult to understand the diference of them and the use of method: :patch or even url: articles_path, once both are unified by using the partial _form.html.erb. What is strange too is that the resulting html form into the browser for both use the same action 'POST'. Shouldn't be PATCH or PUT for the **edit** form instead?What is not clear too, is how does the _form.html.erb produces diferent paths once the code is the same. What I think that would explain is: 1 - For edit, an existing object is sent to the form. For new a new object is sent and this one was not saved yet. 2 - Considering item 1 as true a new object, references/has/generates an url diferent from an existing according to its “age/status”.
Am I wrong?
Tks, Alexandre.