我需要添加什么到 config.rb 来解决这个问题。
由于我对 Rails 的了解非常有限,我设法将此方法放入控制器中。
def reset
Player.each do |p|
p.playing = false
p.save
end
end
并在视图中创建此链接
<p><%= link_to "New Game", {:action => 'reset' }%></p>
我只是不确定在 routes.rb 中放什么来让它工作而不会填满我已经拥有的东西。
这是我的 config.rb
ChooseTeams3::Application.routes.draw do
resources :players
root :to => "players#index"
get "/index" => "players#index"
end
如果我输入 rake routes 我会得到这个
rake routes
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
root / players#index
index GET /index(.:format) players#index