这个错误正在发生,我不知道为什么,谢谢,未定义的方法`article_path‘for #<#:0x000001029cb960>
edit.html.erb
<h1>Editing <%= @article.name %></h1>
<%= form_for(@article) do |f| %> <-- ????something here?
<p>
<%= f.label :name %><br />
<%= f.text_field :name %>
</p>
<p>
<%= f.submit %>
</p>
<% end %>文章模型
class MediaController < ApplicationController
def index
@articles = Articles.all
end
def show
@article = Articles.find(params[:id])
end
def edit
@article = Articles.find(params[:id])
end
def update
@article.find(params[:id])
article_params = params.require(:article).permit(:name, :description, :location)
@article.update(article_params)
redirect_to @article
end
endroutes.rb
resources :media
patch "events/:id" => "media#update", as: "update_medium"发布于 2014-03-25 04:51:14
改变你的路线
patch "articles/:id" => "media#update", as: "update_medium"并将模型名称改为单数如下:
@articles = Article.allhttps://stackoverflow.com/questions/22625525
复制相似问题