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 %>