我要將投票系統添加到我的rails應用程序,並嘗試使用activerecord-reputation-system gem運行信譽系統,其次是railscasts #364視頻。路由錯誤 - 沒有路由匹配使用activerecord-reputation-system gem in rails的[GET]錯誤
我掙扎在路由錯誤,當我點擊給予好評或downvote,它顯示了一個錯誤「無路由匹配[GET] 「/俳句/ 1 /票」
/config/routes.rb:
Youhaiku::Application.routes.draw do
get 'signup', to: 'users#new', as: 'signup'
get 'login', to: 'sessions#new', as: 'login'
get 'logout', to: 'sessions#destroy', as: 'logout'
resources :users
resources :sessions
resources :haikus do
member { post :vote }
end
root to: 'haikus#index'
end
/app/controllers/haikus_controller.rb:
def vote
value = params[:type] == "up" ? 1 : -1
@haiku = Haiku.find(params[:id])
@haiku.add_evaluation(:votes, value, current_user)
redirect_to :back, notice: "Thank you for voting!"
end
/app/views/haikus/_haiku.html.erb:
<div class="haiku">
<%= simple_format haiku.content %>
<em>
-- <%= haiku.user.name %>
| <%= link_to "up", vote_haiku_path(haiku, type: "up"), method: "post" %>
| <%= link_to "down", vote_haiku_path(haiku, type: "down"), method: "post" %>
</em>
</div>
我檢查了這個issue但這不是幫助我。所以,我真的需要幫助。
試試這個'<%= link_to「up」,vote_haiku_path(ha句,類型:「up」),方法:: post%>' –
是的,我已經嘗試過了,但它不適合我! – diya
你能否粘貼你在呈現這個鏈接後得到的html。 –