Ruby on Rails
Tuesday, May 28, 2019
My Schema.rb is below
-- ActiveRecord::Schema.define(version: 2019_05_27_040649) do
create_table "days", force: :cascade do |t|
t.integer "season_id"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.date "raceday"
t.index ["season_id"], name: "index_days_on_season_id"
end
create_table "points", force: :cascade do |t|
t.text "place"
t.text "riders"
t.integer "racepoints"
t.text "status"
t.integer "race_id"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["race_id"], name: "index_points_on_race_id"
end
create_table "races", force: :cascade do |t|
t.boolean "display"
t.text "racename"
t.integer "season_id"
t.integer "day_id"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.text "raceclass"
t.index ["day_id"], name: "index_races_on_day_id"
t.index ["season_id"], name: "index_races_on_season_id"
end
create_table "seasons", force: :cascade do |t|
t.date "year"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
end
end
I want to end up with something like this for the race index.html.erb file
You select the season it then displays the days for the the selected season. You then select the day and the races for that day are displayed.
The four tables are joined and the results is displayed in the Race Details.
My current points index.html is this.
<p id="notice"><%= notice %></p>
<h1>Points</h1>
<div class ='row'>
<div class="control-group">
<div class= 'pointsLabel'>Season</div>
<div class='controls'>
<%= collection_select(:season, :id, Season.all, :id, :year, {}, {:multiple => false}) %>
</div>
</div>
</div><br>
<div class ='row'>
<div class="control-group">
<div class= 'pointsLabel'>Race Day</div>
<div class='controls'>
<%= collection_select(:day, :id, Day.all, :id, :raceday, {}, {:multiple => false}) %>
</div>
</div>
</div><br>
<div class ='row'>
<div class="control-group">
<div class= 'pointsLabel'>Race Name</div>
<div class='controls'>
<%= collection_select(:race, :id, Race.all, :id, :racename, {}, {:multiple => false}) %>
</div>
</div>
</div><br>
<br>
I am thinking of using a grouped_collection_select to populate the relevant dropdowns . I know I need to Jquery or javascript to pass the selected options from one drop down to another .but can't get it to work
Cheers Dave
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/39724b42-3377-44b4-8171-7635059f1f13%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment