Ruby on rails 路由错误&引用;ActionController::RoutingError(没有与[PATCH]匹配的路由;

Ruby on rails 路由错误&引用;ActionController::RoutingError(没有与[PATCH]匹配的路由;,ruby-on-rails,ruby,model-view-controller,routing,Ruby On Rails,Ruby,Model View Controller,Routing,当用户使用此表单单击提交时: <%= simple_form_for(@routine, url: create_freebie_routine_path(params[:id])) do |f| %> <%= f.date_select %> <% end %> 例行程序\u控制器 def new_freebie @routine = current_user.routines.find(params[:id]) @routin

当用户使用此表单单击提交时:

<%= simple_form_for(@routine, url: create_freebie_routine_path(params[:id])) do |f| %>

  <%= f.date_select %>

<% end %>
例行程序\u控制器

  def new_freebie
    @routine = current_user.routines.find(params[:id])
    @routine.freebie_date = Date.yesterday
    respond_modal_with @routine
  end

  def create_freebie
    @routine = current_user.routines.find(params[:id])
    @routine.freebie = @routine.freebie + 1
    @routine.save
    respond_modal_with @routine, location: root_path
    flash[:alert] = 'Freebie added'
  end

谢谢你的帮助!

你必须更换这个

  resources :routines do
    member do
      get :new_freebie
      post :create_freebie
    end
  end
与:

注意从
post
patch


另一种解决方案是在表单中指定
方法
post
,而不更改
路由

<%= simple_form_for @routine, url: create_freebie_routine_path(params[:id]), method: :post do |f| %>

  <%= f.date_select %>

<% end %>

您必须更换此

  resources :routines do
    member do
      get :new_freebie
      post :create_freebie
    end
  end
与:

注意从
post
patch


另一种解决方案是在表单中指定
方法
post
,而不更改
路由

<%= simple_form_for @routine, url: create_freebie_routine_path(params[:id]), method: :post do |f| %>

  <%= f.date_select %>

<% end %>