在我dafault
頁我有一個按鈕pending request
,當我在pending request
按鈕點擊路由錯誤,那麼它去我的pending request
頁面,下面是pending request
按鈕代碼上接受請求按鈕
<table>
<tr>
<td style="color: #212121;">
<div class="button">
<%= button_to "Pending Request", '/pendingrequest', { method: :get, :class => "buttonhome" } %>
</div>
</td>
</tr>
</table>
及以下的pending request
路線:
match '/pendingrequest', to: 'static_pages#pending_request', via: 'get'
,並在pending request
頁,我收到來自用戶和隨着次請求ESE要求兩個按鈕accept
和ignore
是即低於附:
<table width="50%">
<tr>
<td align="center">
<div class="button">
<%= button_to "Accept", "/accept", { method: :post, :class => "buttonblck" } %>
</div>
</td>
<td align= "center">
<div class="button">
<%= button_to "Ignore", '/default', { method: :get, :class => "buttonblck" } %>
</div>
</td>
</tr>
</table>
當我在accept
按鈕點擊,我的請求已被接受,我做接受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
,但是當我點擊accept
按鈕,它使我的錯誤如下:
No route matches [POST] "/pendingrequest"
但"/pendingrequest"
是pending request
頁面的網址,爲什麼它會在accept
按鈕上發生此錯誤。以下是accept
按鈕的路線:
match '/accept', to: 'static_pages#create', via: 'post'
請幫助我,等你答覆。 謝謝