Skip to content

Commit

Permalink
set last verified on, on before create document
Browse files Browse the repository at this point in the history
  • Loading branch information
tsubik committed Jul 22, 2019
1 parent 74b95d6 commit 1048bf9
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
6 changes: 6 additions & 0 deletions app/admin/documents.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,10 @@
column :last_verified_on
actions
end

controller do
def scoped_collection
super.includes(:documentable)
end
end
end
6 changes: 5 additions & 1 deletion app/admin/litigations.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

permit_params :title, :location_id, :document_type, :summary, :core_objective,
documents_attributes: [
:id, :_destroy, :name, :external_url, :file
:id, :_destroy, :name, :external_url, :type, :file
]

filter :title_contains
Expand Down Expand Up @@ -58,6 +58,10 @@
form partial: 'form'

controller do
def scoped_collection
super.includes(:location)
end

def find_resource
scoped_collection.friendly.find(params[:id])
end
Expand Down
2 changes: 1 addition & 1 deletion app/models/document.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class Document < ApplicationRecord

has_one_attached :file

before_save :set_last_verified_on
before_create :set_last_verified_on

validates :external_url, url: true, presence: true, if: :external?
validates :file, attached: true, if: :uploaded?
Expand Down

0 comments on commit 1048bf9

Please sign in to comment.