【发布时间】:2016-07-26 09:26:30
【问题描述】:
我在使用 simple_form_for 时遇到路由问题。我知道这与复数有关,但相同的形式非常适合编辑/更新方法。
undefined method `companies_path'
Did you mean? companys_path
company_path
companys_controller
def new
@company = Company.new
end
def create
@company = Company.new(company_params)
if @company.save
redirect_to @company
else
render 'new'
end
end
_form.html.haml
= simple_form_for @company do |f|
= f.input :name
= f.input :description
= f.input :website
= f.button :submit
耙路
companys GET /companys(.:format) companys#index
POST /companys(.:format) companys#create
new_company GET /companys/new(.:format) companys#new
edit_company GET /companys/:id/edit(.:format) companys#edit
company GET /companys/:id(.:format) companys#show
PATCH /companys/:id(.:format) companys#update
PUT /companys/:id(.:format) companys#update
DELETE /companys/:id(.:format) companys#destroy
我想问题是,Edit/update 用于“companys_path”,而 new/create 用于“companies_path”。任何帮助表示赞赏。
【问题讨论】:
标签: ruby-on-rails ruby ruby-on-rails-4