Fix numbers autoincrement
This commit is contained in:
parent
63590c9e92
commit
1cdf5048c3
6 changed files with 16 additions and 5 deletions
|
|
@ -52,7 +52,9 @@ class Check < ApplicationRecord
|
|||
:standard_text,
|
||||
:powerpoint_text
|
||||
|
||||
after_create { update(number: id) unless number }
|
||||
validates :number, uniqueness: true, presence: true
|
||||
|
||||
before_validation { self.number = self.class.maximum(:id).to_i + 1 unless self.number.present? }
|
||||
|
||||
scope(:search, lambda { |term|
|
||||
# TODO: Search only fields for current locale.
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
= bootstrap_form_with(model: check, remote: true) do |form|
|
||||
h2 Details
|
||||
= multilang_form_field(form, :name)
|
||||
= form.text_field :number
|
||||
= form.text_field :number, required: false
|
||||
.row
|
||||
= form.collection_radio_buttons(:principle_id, Principle.all.sort_by(&:t_name), :id, :t_name) { |b| b.label(class: "col-md-2") { b.radio_button + b.text } }
|
||||
= form.collection_check_boxes :standard_ids, Standard.all.sort_by{ _1.t_name.downcase }, :id, :t_name, include_blank: true
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue