Commit 7047a44a26f0f75ab23c58c47d096060c01256ed
1 parent
125c07fa
Exists in
master
and in
4 other branches
Sett iid on create. Use iid as value to_param
Showing
2 changed files
with
16 additions
and
0 deletions
Show diff stats
app/models/concerns/issuable.rb
... | ... | @@ -16,6 +16,7 @@ module Issuable |
16 | 16 | |
17 | 17 | validates :author, presence: true |
18 | 18 | validates :title, presence: true, length: { within: 0..255 } |
19 | + validates :iid, presence: true, numericality: true | |
19 | 20 | |
20 | 21 | scope :authored, ->(user) { where(author_id: user) } |
21 | 22 | scope :assigned_to, ->(u) { where(assignee_id: u.id)} |
... | ... | @@ -24,6 +25,8 @@ module Issuable |
24 | 25 | scope :unassigned, -> { where("assignee_id IS NULL") } |
25 | 26 | scope :of_projects, ->(ids) { where(project_id: ids) } |
26 | 27 | |
28 | + validate :set_iid, on: :create | |
29 | + | |
27 | 30 | delegate :name, |
28 | 31 | :email, |
29 | 32 | to: :author, |
... | ... | @@ -44,6 +47,15 @@ module Issuable |
44 | 47 | end |
45 | 48 | end |
46 | 49 | |
50 | + def set_iid | |
51 | + max_iid = project.send(self.class.name.tableize).maximum(:iid) | |
52 | + self.iid = max_iid.to_i + 1 | |
53 | + end | |
54 | + | |
55 | + def to_param | |
56 | + iid.to_s | |
57 | + end | |
58 | + | |
47 | 59 | def today? |
48 | 60 | Date.today == created_at.to_date |
49 | 61 | end | ... | ... |
app/models/merge_request.rb