도움이 필요합니다. ROR을 사용하여 양식 데이터를 게시하는 동안 다음과 같은 오류가 발생합니다.ROR을 사용하여 양식을 제출하는 동안 라우팅 오류가 발생했습니다.
No route matches [POST] "/articles/new"
Rails.root: C:/Sites/blog
Application Trace | Framework Trace | Full Trace
Routes
Routes match in priority from top to bottom
Helper HTTP Verb Path Controller#Action
Path/Url
articles_path GET /articles(.:format) articles#index
POST /articles(.:format) articles#create
new_article_path GET /articles/new(.:format) articles#new
edit_article_path GET /articles/:id/edit(.:format) articles#edit
article_path GET /articles/:id(.:format) articles#show
PATCH /articles/:id(.:format) articles#up
아래 코드를 설명하고 있습니다.
new.html.erb :
<%= form_for @article do |f| %>
<p>
<%= f.label :title %><br>
<%= f.text_field :title %>
</p>
<p>
<%= f.label :text %><br>
<%= f.text_area :text %>
</p>
<p>
<%= f.submit %>
</p>
<% end %>
date
사용자가이 형태를 그 오류 유형을 제출한다 route.rb
파일 아래에 주어진다 coming.My이다.
Rails.application.routes.draw do
resources :articles
root 'welcome#index'
end
내 컨트롤러 파일 코드는 아래와 같습니다.
class ArticlesController < ApplicationController
def new
end
def create
@article = Article.new(article_params)
if @article.save
redirect_to @article
else
render 'new'
end
end
end
이 오류를 해결하는 데 도움 호야 레일즈 버전 4.2...
를 사용하고 있습니다.
기본 레일을'new' 행동이'수/기사/new'를 얻을 수 있지만, 기본'create' 동작이'POST/articles' 될 것입니다 (없이 마지막에는'/ new'); 양식이 잘못된 URL에 제출되고 있습니다. 그건 그렇고,'def new '컨트롤러 메소드에'@article = Article.new'가 들어 있지 않아야합니까? – GoBusto
답을 편집 할 수 있습니까? – subhra