Skip to content

Commit 83fb9d8

Browse files
committed
tracker: assigned_to_user_id has to contain the user.id and not the account.id
1 parent 27561a0 commit 83fb9d8

File tree

4 files changed

+20
-3
lines changed

4 files changed

+20
-3
lines changed

app/views/trackers/_form.html.haml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
= form.select :state, Tracker::States.invert
2020
%p
2121
= form.label :assigned_to_user_id, "Assigné à"
22-
= form.collection_select :assigned_to_user_id, Account.admin, :id, :login, include_blank: true
22+
= form.collection_select :assigned_to_user_id, Account.admin, :user_id, :login, include_blank: true
2323
%p
2424
= form.submit "Prévisualiser", id: "tracker_preview"
2525
= form.submit "Soumettre", 'data-disable-with' => "Enregistrement en cours" if @preview_mode || @tracker.persisted?

app/views/trackers/index.html.haml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
= f.collection_select :category_id, Category.all, :id, :title, include_blank: true
2323
%p
2424
= f.label :assigned_to_user_id, "Assigné à : "
25-
= f.collection_select :assigned_to_user_id, Account.admin, :id, :name, include_blank: true
25+
= f.collection_select :assigned_to_user_id, Account.admin, :user_id, :name, include_blank: true
2626
%p
2727
= label_tag :order, "Trier par : "
2828
= select_tag :order, options_for_select({ "Date d’ouverture" => "created_at", "Note" => "score", "Nombre de commentaires" => "comments_count", "Dernier commentaire" => "last_commented_at" }, @order)
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
class FixAssignedUserIdFromTracker < ActiveRecord::Migration[5.2]
2+
def up
3+
execute <<-SQL
4+
UPDATE trackers
5+
SET assigned_to_user_id = (SELECT user_id FROM accounts WHERE accounts.id = trackers.assigned_to_user_id)
6+
WHERE assigned_to_user_id is NOT NULL;
7+
SQL
8+
end
9+
10+
def down
11+
execute <<-SQL
12+
UPDATE trackers
13+
SET assigned_to_user_id = (SELECT id FROM accounts WHERE accounts.user_id = trackers.assigned_to_user_id)
14+
WHERE assigned_to_user_id is NOT NULL;
15+
SQL
16+
end
17+
end

db/schema.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
#
1111
# It's strongly recommended that you check this file into your version control system.
1212

13-
ActiveRecord::Schema.define(version: 2019_05_18_110400) do
13+
ActiveRecord::Schema.define(version: 2021_01_31_231806) do
1414

1515
create_table "accounts", id: :integer, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci", force: :cascade do |t|
1616
t.integer "user_id"

0 commit comments

Comments
 (0)