当我单击“项目”显示页面上的“新计划状态”按钮时,错误显示的路线是复数,而它应该是单数。这是我的代码:
# project.rb
class Project < ActiveRecord::Base
has_one :schedule_status
end
# schedule_status.rb
class ScheduleStatus < ActiveRecord::Base
belongs_to :project
end
# schedule_statuses_controller.rb
def new
@project = Project.find(params[:project_id])
@schedule_status = @project.build_schedule_status
end
# routes.rb
resources :projects do
resource :schedule_status
end
# _form.html.erb
<%= form_for [@project, @schedule_status] do |f| %>
...
该错误告诉我我的form_for
行不正确。似乎我的实例变量设置正确,但错误是:
undefined method `project_schedule_statuses_path` for ...
知道为什么它尝试访问的路线是复数吗?