diff --git a/db/schema.rb b/db/schema.rb index fd4484e..887f52a 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema[7.2].define(version: 2025_03_21_235135) do +ActiveRecord::Schema[7.2].define(version: 2025_03_22_172051) do create_table "candidates", force: :cascade do |t| t.integer "vote_id" t.string "name" @@ -26,8 +26,10 @@ ActiveRecord::Schema[7.2].define(version: 2025_03_21_235135) do t.integer "value" t.datetime "created_at", null: false t.datetime "updated_at", null: false + t.integer "vote_id", null: false t.index ["candidate_id"], name: "index_ratings_on_candidate_id" t.index ["user_id"], name: "index_ratings_on_user_id" + t.index ["vote_id"], name: "index_ratings_on_vote_id" end create_table "users", force: :cascade do |t| @@ -45,4 +47,6 @@ ActiveRecord::Schema[7.2].define(version: 2025_03_21_235135) do t.datetime "created_at", null: false t.datetime "updated_at", null: false end + + add_foreign_key "ratings", "votes" end diff --git a/views/votes_show.erb b/views/votes_show.erb index 052e20f..206740b 100644 --- a/views/votes_show.erb +++ b/views/votes_show.erb @@ -13,13 +13,13 @@
<%= candidate.name %>
<%= candidate.description %>
| Participant | + <% @vote.candidates.each do |candidate| %> +<%= candidate.name %> | + <% end %> +
|---|---|
| <%= user.email %> | + <% @vote.candidates.each do |candidate| %> + <% if rating = @vote.ratings.find { |rating| rating.user == user and rating.candidate == candidate } %> +<%= rating.value %> | + <% end %> + <% end %> +