简体   繁体   English

ActionController :: MethodNotAllowed(仅允许获取,放置和删除请求。)

[英]ActionController::MethodNotAllowed (Only get, put, and delete requests are allowed.)

I'm getting this error, ActionController::MethodNotAllowed (Only get, put, and delete requests are allowed.), when I try to submit a form. 当我尝试提交表单时,出现此错误ActionController :: MethodNotAllowed(仅允许获取,放置和删除请求。)。 My route looks like this, 我的路线看起来像这样

admin.resources :email_launcher admin.resources:email_launcher

and this is my form_for, 这是我的form_for,

  • form_for :email_launcher, :url => new_admin_email_launcher_path, :method => :get do |f| form_for:email_launcher,:url => new_admin_email_launcher_path,:method =>:get do | f |

This is not in a form but in the new view, and I'm using HAML. 这不是表单,而是新视图,并且我正在使用HAML。 I've google searched all day on the error but never found anything of value. 我整天都在Google上搜索错误,但从未发现任何有价值的东西。 Any help would be great, thanks. 任何帮助将是巨大的,谢谢。

Here's my rake routes for admin_email_launcher 这是我的admin_email_launcher耙路

                          admin_email_launcher_index GET     /admin/email_launcher(.:format)                                                {:controller=>"admin/email_launcher", :action=>"index"}
                                                     POST    /admin/email_launcher(.:format)                                                {:controller=>"admin/email_launcher", :action=>"create"}
                            new_admin_email_launcher GET     /admin/email_launcher/new(.:format)                                            {:controller=>"admin/email_launcher", :action=>"new"}
                           edit_admin_email_launcher GET     /admin/email_launcher/:id/edit(.:format)                                       {:controller=>"admin/email_launcher", :action=>"edit"}
                                                     GET     /admin/email_launcher/:id(.:format)                                            {:controller=>"admin/email_launcher", :action=>"show"}
                                                     PUT     /admin/email_launcher/:id(.:format)                                            {:controller=>"admin/email_launcher", :action=>"update"}
                                                     DELETE  /admin/email_launcher/:id(.:format)                                            {:controller=>"admin/email_launcher", :action=>"destroy"}

routes.rb routes.rb

namespace :admin do
  resources :email_launcher
end

admin/email_launchers_controller.rb 管理员/email_launchers_controller.rb

def new
  @email_launcher = EmailLauncher.new
end

admin/email_launcher/new 管理员/电子邮件启动器/新

<%= form_for([:admin,@email_launcher]) do |f| %>
  ...
  <%= f.submit %>
<% end -%>

It will POST new email_launcher. 它将发布新的email_launcher。 Why do you need to GET the new action? 为什么需要执行新操作? You're already on the new page. 您已经在新页面上了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM