这是我的路线
resources :games do
resources :message_templates, :shallow => true
我的佣金路线就像这样
game_message_templates GET /games/:game_id/message_templates(.:format) message_templates#index
POST /games/:game_id/message_templates(.:format) message_templates#create
new_game_message_template GET /games/:game_id/message_templates/new(.:format) message_templates#new
edit_message_template GET /message_templates/:id/edit(.:format) message_templates#edit
message_template GET /message_templates/:id(.:format) message_templates#show
PUT /message_templates/:id(.:format) message_templates#update
DELETE /message_templates/:id(.:format) message_templates#destroy
和我的_form.erb,看起来像这样
<% form_for(@message_template) do |f| %>
但我收到此错误
undefined method `message_templates_path'
答案 0 :(得分:2)
看起来您正在为给定游戏创建新的消息模板,在这种情况下,您需要提供具有相关游戏的路线。如果它是现有的消息模板,则路径为message_template_path而不是message_templates_path。
说:
<% form_for([@game, @message_template]) do |f| %>