### route
resources :flow_templates do
resources :flow_details, shallow: true
end
### Model
class FlowTemplate < ActiveRecord::Base
has_many :details, class_name: :FlowDetail, foreign_key: :template_id
end
class FlowDetail < ActiveRecord::Base
belongs_to :template, class_name: :FlowTemplate, foreign_key: :template_id
end
### Controller
class FlowTemplatesController < ApplicationController
inherit_resources
actions :all, except: [:show]
private
def flow_template_params
params.require(:flow_template).permit!
end
end
class FlowDetailsController < ApplicationController
inherit_resources
belongs_to :FlowTemplate
private
def flow_detail_params
params.require(:flow_detail).permit!
end
end
### error
http://127.0.0.1:5000/flow_templates/1/flow_details/new
Couldn't find FlowTemplate without an ID