Я пытаюсь создать форму на моей странице 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
грабли задачи
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