[英]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.