Dear list,
I got a database with two tables, ‘bets’ and ‘matches’.
When placing a bet, I would like to have a [Match number] dropdown menu
listing the primary_key to all existing matches in the ‘matches’ table.
This connecting the bet to a known upcoming match.
Would any of you gentlemen please give me some help?
app/views/bets/new.rhtml:
<% form_tag :action => ‘create’ do %>
<%= render :partial => ‘form’ %>
<%= submit_tag “Create” %>
<% end %>
<%= link_to ‘Back’, :action => ‘list’ %>
app/views/bets/_form.rhtml:
Gambler
<%= text_field 'bet', 'gambler' %>
Game
<%= text_field 'bet', 'game' %>
Hjemme
<%= text_field 'bet', 'hjemme' %>
Borte
<%= text_field 'bet', 'borte' %>
Amount of money
placed
<%= text_field 'bet', 'amount_of_money_placed' %>
scheme.rb:
create_table “bets”, :force => true do |t|
t.column “gambler”, :string
t.column “game”, :integer
t.column “hjemme”, :integer
t.column “borte”, :integer
t.column “bet_placed_at”, :datetime
t.column “amount_of_money_placed”, :integer
end
create_table “matches”, :force => true do |t|
t.column “hjemmelag”, :string
t.column “bortelag”, :string
t.column “arena”, :string
t.column “date”, :datetime
t.column “goals_home”, :decimal
t.column “goals_away”, :decimal
end
end
All help is highly appreciated!
Best regards,
Martin S.