简体   繁体   English

rails heroku错误:未定义路线,但路线存在(您要查找的页面不存在。)

[英]rails heroku error: no route defined, but route is there (The page you were looking for doesn't exist.)

I am getting a strange error on heroku. 我在heroku上遇到一个奇怪的错误。 So I have an adress ressource that belongs to a user. 所以我有一个属于用户的adress资源。 A user can have multiple adresses, eg shipping and billing. 用户可以具有多个地址,例如运输和开票。

of course I have 当然,我有

  resources :adresses

in my routes and all (scaffolded) REST controller actions. 在我的路线和所有(脚手架)REST控制器操作中。

now in my view I have the following statement: 现在我认为我有以下陈述:

<%= button_to "Edit", edit_adress_path(@adress), :class => "edit_adress funkybutton" %>

which generates the following html: 生成以下html:

<form class="button_to" action="/adresses/7/edit?locale=en" method="post"><div><input type="submit" value="Edit" class="edit_adress funkybutton"><input type="hidden" value="d/s1KOUtYao+ieqJN3xAz2jrmGPcvF06LjKKHxnFc+o=" name="authenticity_token"></div></form>

Now whenever I click that button, I get the an error page on heroku saying 现在,每当我单击该按钮时,我都会在heroku上看到一个错误页面,说

The page you were looking for doesn't exist.

You may have mistyped the address or the page may have moved.

When I type heroku logs I get: 当我输入heroku logs我得到:

2012-03-12T18:49:02+00:00 app[web.1]: Started POST "/adresses/7/edit?locale=en" for 85.177.82.243 at 2012-03-12 11:49:02 -0700
2012-03-12T18:49:02+00:00 app[web.1]: 
2012-03-12T18:49:02+00:00 app[web.1]: 
2012-03-12T18:49:02+00:00 app[web.1]: ActionController::RoutingError (No route matches "/adresses/7/edit"):

which seems very odd to me. 这对我来说似乎很奇怪。 Even stranger is that when I click in my browsers adress bar after and hit enter, it displays the edit form just fine. 甚至更奇怪的是,当我在浏览器中的地址栏后单击并按Enter时,它会显示编辑表单。 So it works, but every single time I click on the button I get this error message. 这样就可以了,但是每次我单击按钮时,都会收到此错误消息。 I have no idea whatsoever could be causing the error and hope somebody can help. 我不知道会导致该错误的任何原因,希望有人能提供帮助。 Thanks! 谢谢!

Btw. 顺便说一句。 I am on Rails 3.0.5 我在Rails 3.0.5上

The button_to is creating a POST request to /addresses/7/edit which resources doesn't define a route for. button_to正在为/addresses/7/edit创建POST请求,该请求的resources未定义路由。 When you manually go to the link in your browser it's creating a GET request, which routes to the edit action. 当您手动转到浏览器中的链接时,它正在创建一个GET请求,该请求将路由到edit操作。

You can change the button_to call to use a GET method: 您可以将button_to调用更改为使用GET方法:

<%= button_to "Edit", edit_adress_path(@adress), :class => "edit_adress funkybutton", :method => :get %>

暂无
暂无

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

相关问题 Heroku Rails设置“您正在寻找的页面不存在。” - Heroku Rails Setup “The page you were looking for doesn't exist.” 无法在heroku上部署应用程序,总是得到“您要查找的页面不存在。”错误 - Can't deploy app on heroku, always get “The page you were looking for doesn't exist.” error Rails / Heroku您正在寻找的页面不存在 - Rails/Heroku The page you were looking for doesn't exist Ruby on Rails / Heroku-您要查找的页面不存在 - Ruby on Rails / Heroku - The page you were looking for doesn't exist 您要查找的页面不存在 - heroku + rails - The page you were looking for doesn't exist - heroku+rails 在商店上安装后的Heroku Shopify应用程序“您要查找的页面不存在。” - Heroku Shopify App after installation on shop “The page you were looking for doesn't exist.” heroku“您要查找的页面不存在。”遵循Hartl的RoR指南 - heroku “The page you were looking for doesn't exist.” following Hartl's RoR guide Cloud9,GitHub和Heroku(您要查找的页面不存在。) - Cloud9, GitHub and Heroku (The page you were looking for doesn't exist.) “您要查找的页面不存在。”编辑表单 - “The page you were looking for doesn't exist.” edit form 为什么当我在Heroku的另一个窗口中打开新链接时显示“您要查找的页面不存在”的原因。 - Why is it when I open a new link in another window on Heroku it says “The page you were looking for doesn't exist.”
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM