I have a controller games
and a method:
def index
@games = Game.all
end
def set_game
@current_game = Game.find(params[:set_game])
end
In my view I have:
<%= form_tag("/games") do %>
<% @games.each do |g| %>
<%= radio_button_tag(:game_id, g.id) %>
<%= label_tag(:game_name, g.name) %><br>
<% end %>
<%= submit_tag "Confirm" %>
<% end %>
Routes:
resources :games
match 'games', :to => 'game#index'
How can I make this form work for my set_game
method?
Thanks.
<%= form_tag(set_game_games_path) do %>
...
<% end %>
#routes.rb
resources :games do
collection do
get '/set_game', :as => :set_game
end
end
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With