2012-03-25 12 views
0

私のレールルートファイルに問題があります。私は私のルートファイルに次の試合を持っている:Railsルーティングの問題 - 初期化されていないコンスタントゲーム

<%= link_to 'Cool!', games_incrementcool_path(@game) %> 

を私はルーティングエラーuninitialized constant Gamesを受け付けております:

match '/games/:game_id/increment_cool' => 'games/:game_id#increment_cool', :as => 'games_incrementcool' 

私はその後、私のゲームはとても気に入りましたから、このルートを使用するようにしてください。

すくいルートこれを示しています

(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メソッドを呼び出すために私のビューを取得するにはどうすればよいですか?前もって感謝します!

+0

game_incrementcool_pathにする必要はありませんか?このエラーは、RoRマジックがゲームモデルではなくゲームモデルを探していることを示しています。 –

答えて

0

これはマッチの動作方法である:match '/posts' => 'posts#index'

最初の文字列はルートであり、2番目の文字列は、#で区切られたコントローラ/アクションの組み合わせです。

'games#increment_cool'は、gamesコントローラのincrement_coolアクションを表します。

match '/games/:game_id/increment_cool' => 'games#increment_cool', :as => 'games_incrementcool'

それが特異資源に取り組んでいますので、あなたはおそらく、セマンティックな理由から、あなたの:asオプションで単数「ゲーム」を使用する必要がありますが。多分game_increment_coolincrement_cool_gameのようなものでしょう。

関連する問題