RoR'nin yol değişken özelliğini yani new_game_path'u kullanabilmem için yeni bir yol oluşturmaya çalışıyorum. Benim durumumda, ben uygun denetleyicisi için bir eylem oluşturulan ve halen şöyle yönlendirmiş load_game_pathRuby On Rails özel rotası her zaman denetleyicinin show eylemine yeniden yönlendirir
kullanmak istiyorum:
resources :games do
get 'load', on: :collection
end
Her zaman load_games_path kullanmak doğru URI kullanır ancak GamesController'ın gösteri eylemine yeniden yönlendirme yapıyor ve Oyunların devralma gösterisi görünümünü görüntüler.
Ben tırmık yolları kontrol ettim ve istenilen yol/oyunlar/yük gibi görünüyor ne ile benim yeni oluşturulan rota (bkz dosyası yolu: /views/games/load.html.erb)
load_games GET /games/load(.:format) games#load/
Rake Yolları:
welcome_index GET /welcome/index(.:format) welcome#index
players GET /players(.:format) players#index
POST /players(.:format) players#create
new_player GET /players/new(.:format) players#new
edit_player GET /players/:id/edit(.:format) players#edit
player GET /players/:id(.:format) players#show
PUT /players/:id(.:format) players#update
DELETE /players/:id(.:format) players#destroy
games GET /games(.:format) games#index
POST /games(.:format) games#create
new_game GET /games/new(.:format) games#new
edit_game GET /games/:id/edit(.:format) games#edit
game GET /games/:id(.:format) games#show
PUT /games/:id(.:format) games#update
DELETE /games/:id(.:format) games#destroy
users GET /users(.:format) users#index
POST /users(.:format) users#create
new_user GET /users/new(.:format) users#new
edit_user GET /users/:id/edit(.:format) users#edit
user GET /users/:id(.:format) users#show
PUT /users/:id(.:format) users#update
DELETE /users/:id(.:format) users#destroy
/players/:name(.:format) players#index
load_games GET /games/load(.:format) games#load
GET /games(.:format) games#index
POST /games(.:format) games#create
GET /games/new(.:format) games#new
GET /games/:id/edit(.:format) games#edit
GET /games/:id(.:format) games#show
PUT /games/:id(.:format) games#update
DELETE /games/:id(.:format) games#destroy
root / welcome#index
routes.rb:
get "welcome/index"
resources :players, :games, :users
match '/players/:name' => 'players#index'
# match 'games/load(.:format)', :controller => 'games', :action => 'load'
resources :games do
collection do
get 'load'
end
end
root :to => 'welcome#index'
Arama Ben Bu yük, denetleyici için önceden tanımlanmış bir eylemdir. Bunun bir sorun olmadığından emin olmak için, aynı sonuçları elde etmek için eylem için keyfi bir isim denedim. id parametresi: ile: 'id oyunları /'
match 'games/load(.:format)', :controller => 'games', :action => 'load'
Günlük ne diyor? Hangi eylemin çağrıldığını size söyleyecektir. – Substantial
İşte günlüğün bir pasajı. Gösteri eylemini çağırmaya çalıştığını görebilirsiniz. HTML id => 'load' parametresinin ne anlama geldiğinden emin değil. 'GET "/ oyunlar/yük" için 127.0.0.1 at 2013-07-25 21:07:36 -0400 İşlemlere ait OyunlarController # HTML olarak göster Parametreler: {"id" => "load"} Tamamlanmış 500 Dahili Sunucu Hatası 4ms ActionView :: MissingTemplate (Eksik şablon oyunları/show, uygulama/show with {: locale => [: en],: format => [: html],: işleyicileri => [: arama sonuçları: * "W:/Rails/testApp/blog/app/görünümler" ): actionpack ' – Andrew
Buradan' rake route 'sonucunu yapıştırabilir misiniz? Sadece oyunlar ile ilgili ve haklı düzen ile ilgili olanlar. Çünkü sanırım "kasıtsız" rotayı yakalayan başka bir yola sahip olduğunuzu ve eylemi göstermek için geçtiğini düşünüyorum. – PeterWong