내 new.html.erb 페이지에서 양식을 만들려고하는데 정의되지 않은 메서드 인 'task_presentations_path'오류가 발생했습니다.다형성 연관을 사용하여 양식을 사용하는 방법
= form_tag [@task, Presentation.new] do |f|
= f.label :summary
= f.text_field :summary
tasks_controller
def new
@task = Task.new
end
루트
resources :presentations do
resources :tasks
end
작업 모델
class Task < ApplicationRecord
belongs_to :taskable, polymorphic: true
has_one :task_type
has_one :task_status
end
프리젠 테이션 모델
,class Presentation < ApplicationRecord
has_many :tasks, as: :taskable
end
레이크 작업
당신의task
모델로
presentation_tasks GET /presentations/:presentation_id/tasks(.:format) tasks#index
POST /presentations/:presentation_id/tasks(.:format) tasks#create
new_presentation_task GET /presentations/:presentation_id/tasks/new(.:format) tasks#new
edit_presentation_task GET /presentations/:presentation_id/tasks/:id/edit(.:format) tasks#edit
presentation_task GET /presentations/:presentation_id/tasks/:id(.:format) tasks#show
PATCH /presentations/:presentation_id/tasks/:id(.:format) tasks#update
PUT /presentations/:presentation_id/tasks/:id(.:format) tasks#update
DELETE /presentations/:presentation_id/tasks/:id(.:format) tasks#destroy
나는'bundle exec rake routes | grep task'를 실행하고 그 경로가 무엇인지 확인하십시오. 보이는 것처럼 그것은 presentation_tasks_path 수 있지만 확실하지 않아요 – mccalljt
컨트롤러 및 모델에 대한 자세한 정보를 추가 할 수 있습니까 ..? – Milind
예 업데이트했습니다. – brandoncodes