Add method Passport#image
This commit is contained in:
parent
40ac9c674b
commit
734e2c6828
3 changed files with 6 additions and 1 deletions
|
@ -24,6 +24,10 @@ class Passport < ApplicationRecord
|
|||
self.patronymic = nil if patronymic.blank?
|
||||
end
|
||||
|
||||
def image
|
||||
images.order(created_at: :desc).last
|
||||
end
|
||||
|
||||
def enough_confirmations?
|
||||
passport_confirmations.count >= REQUIRED_CONFIRMATIONS
|
||||
end
|
||||
|
|
|
@ -137,7 +137,7 @@
|
|||
</dl>
|
||||
</div>
|
||||
|
||||
<% @passport.images.order(created_at: :desc).limit(1).each do |image| %>
|
||||
<% @passport.image.try do |image| %>
|
||||
<div class="col-md-8 col-lg-6">
|
||||
<%= image_tag url_for(image), class: 'img-fluid' %>
|
||||
</div>
|
||||
|
|
|
@ -23,6 +23,7 @@ RSpec.describe Passport do
|
|||
it { is_expected.to validate_presence_of :unit_code }
|
||||
it { is_expected.to validate_presence_of :date_of_issue }
|
||||
|
||||
pending '#image'
|
||||
pending '#enough_confirmations?'
|
||||
|
||||
describe '#patronymic' do
|
||||
|
|
Reference in a new issue