在我的pending request
页面中,我收到了一些来自其他用户的请求,这些请求带有两个按钮,accept
并且cancel
,当我单击接受按钮时,请求被接受,下面是create方法中接受请求的代码
def create
@user = Userrequest.select(:RequestFrom).where('RequestTo = ? AND IsApproved = ?', current_user.id, "0")
requestfrom = @user.RequestFrom
Userrequest.update_attributes('RequestFrom = ? AND RequestTo = ? AND IsApproved = ?', requestfrom,current_user.id,"1")
@user_request = Userrequest.new( :RequestFrom => requestfrom , :RequestTo => current_user.id , :IsApproved => "1" , :SkillType => "" )
@user_request.save
redirect_to '/default'
end
在create方法中,我正在做接受请求工作,接受请求后,它应该重定向到default
页面。但是,当我单击接受按钮时,出现以下错误:
No route matches [POST] "/pendingrequest"
以下是路线:
match '/pendingrequests', to: 'static_pages#create', via: 'get'
以下是我的接受请求按钮:
<table width="50%">
<tr>
<td align="center">
<div class="button">
<%= button_to "Accept", '/pendingrequests', { method: :get, :class => "buttonblck" } %>
</div>
</td>
</tr>
</table>
Kindle建议我在哪里弄错了,等待您的答复。
谢谢
您可以在终端中键入命令:
rake routes
常常有助于理解为什么没有路由数学。
试试这个比赛
match '/static_pages', to: 'static_pages#create', via: :get, as: '/pendingrequests'
或者
match '/static_pages', to: 'static_pages#create', via: :post, as: '/pendingrequests'
或者
match '/static_pages', to: 'static_pages#create', via: :all, as: '/pendingrequests'
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句