我的 rails 路线文件有问题。我的路由文件中有以下匹配项:
match '/games/:game_id/increment_cool' => 'games/:game_id#increment_cool', :as => 'games_incrementcool'
然后我尝试从我的游戏视图中使用这条路线,如下所示:
<%= link_to 'Cool!', games_incrementcool_path(@game) %>
但我收到路由错误uninitialized constant Games
。
rake 路线显示了这一点:
(in /home/sumdeos/RIT48/oneCoolGameADay)
profile_index GET /profile/index(.:format)
new_user_session GET /users/sign_in(.:format)
user_session POST /users/sign_in(.:format)
destroy_user_session DELETE /users/sign_out(.:format)
user_omniauth_callback /users/auth/:action/callback(.r)
user_password POST /users/password(.:format)
new_user_password GET /users/password/new(.:format)
edit_user_password GET /users/password/edit(.:format)
PUT /users/password(.:format)
cancel_user_registration GET /users/cancel(.:format)
user_registration POST /users(.:format)
new_user_registration GET /users/sign_up(.:format)
edit_user_registration GET /users/edit(.:format)
PUT /users(.:format)
DELETE /users(.:format)
submitLeaderboardStatistic_game_leaderboard POST /games/:game_id/leaderboards/:
game_leaderboards GET /games/:game_id/leaderboards(.
POST /games/:game_id/leaderboards(.
new_game_leaderboard GET /games/:game_id/leaderboards/n
edit_game_leaderboard GET /games/:game_id/leaderboards/:
game_leaderboard GET /games/:game_id/leaderboards/:
PUT /games/:game_id/leaderboards/:
DELETE /games/:game_id/leaderboards/:
games GET /games(.:format)
POST /games(.:format)
new_game GET /games/new(.:format)
edit_game GET /games/:id/edit(.:format)
game GET /games/:id(.:format)
PUT /games/:id(.:format)
DELETE /games/:id(.:format)
games_incrementcool /game/:game_id/increment_cool(
home_index GET /home/index(.:format)
root /
我尝试了许多不同的方法来完成这项工作,但没有一个奏效。
如何让我的视图在我的游戏控制器中调用 increment_cool 方法?提前致谢!