Dropdown-menu: listing event in database

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.

Let me rephrase that… :slight_smile:

I want the column “game” in the Bets table to identify which match
I´ve chosen from the Matches table. The dropdown menu letting the user
choose which game, shall include the primary_key to all existing
matches. Or at least somehow identify a game.

Regards,
Martin S.

On 22/02/07, Martin S. [email protected] wrote:

app/views/bets/new.rhtml:

    <p><label for="bet_borte">Borte</label><br/>

create_table “bets”, :force => true do |t|
t.column “bortelag”, :string

Best regards,
Martin S.


Med vennlig hilsen,
Martin S. Mob: 93 44 17 07

A: Because it messes up the way people read text
Q: Why is top-posting such a bad thing?