1
0
mirror of https://github.com/projekteuler/projekteuler.git synced 2026-01-27 02:28:50 +01:00

Show author names in problem and translation views

This commit is contained in:
2019-02-05 12:00:06 +01:00
parent ddb1cfac33
commit 89a8fbba99
14 changed files with 69 additions and 7 deletions

View File

@@ -1,5 +1,6 @@
class Translation < ApplicationRecord
belongs_to :problem, inverse_of: :translations
belongs_to :author, class_name: 'User', inverse_of: :translations, optional: true
enum status: [:pending, :in_use, :outdated, :declined]
validates :title, :content, :problem_id, presence: true
@@ -7,6 +8,10 @@ class Translation < ApplicationRecord
self.per_page = 50
def has_author?
!!self.author
end
def title_is_unique_among_other_problems
Problem.includes(:translation).where.not(id: problem_id).each do |problem|
if problem.is_translated? and problem.title == title