我正在嘗試學習RoR。 我的控制器是路由錯誤未初始化的常量
class SectionController < ApplicationController
def new
if request.post?
u=SectionMst.new(:section_name => params[:section_name])
u.save
redirect_to("/section")
else
render
end
end
def index
@sections = SectionMst.all
end
def destroy
u=SectionMst.destroy(params[:id])
u.save
redirect_to("/section")
end
def edit
@user = SectionMst.find(params[:id])
end
end
和index.html.erb是
<%= link_to "Edit", edit_section_path(section.id), method: :edit %>
耙路線是
section_new POST /section/new(.:format) section#new
POST /section/:id/edit(.:format) section/:id#edit
section_index GET /section(.:format) section#index
POST /section(.:format) section#create
new_section GET /section/new(.:format) section#new
edit_section GET /section/:id/edit(.:format) section#edit
section GET /section/:id(.:format) section#show
PUT /section/:id(.:format) section#update
DELETE /section/:id(.:format) section#destroy
routes.rb中被
post "section/new"
post "section/:id/edit"
resources :section
我得到的 路由錯誤 未初始化的恆定截面
如果刪除的routes.rb中 則第二線我得到 路由錯誤 無路由匹配[POST] 「/部分/ 3 /編輯」
無法得到原因?