Skip to content
Snippets Groups Projects
Commit 2a1ac90f authored by pabois's avatar pabois
Browse files

wip

parent c33e2e04
No related branches found
No related tags found
No related merge requests found
......@@ -33,12 +33,13 @@ class University::Person::Experience < ApplicationRecord
belongs_to :person
belongs_to :organization, class_name: "University::Organization"
validates_presence_of :organization
validates_presence_of :from_year
# TODO validateur de comparaison
# validates_numericality_of :to_year, { greater_than_or_equal_to: :from_year }, allow_nil: true
validate :to_year, :not_before_from_year
after_validation :deport_error_on_organization
scope :ordered, -> { order('university_person_experiences.to_year DESC NULLS FIRST, university_person_experiences.from_year') }
scope :recent, -> {
where.not(from_year: nil)
......@@ -63,4 +64,10 @@ class University::Person::Experience < ApplicationRecord
end
end
def deport_error_on_organization
if errors[:organization] && organization_name
errors.add :organization_name, :required
end
end
end
<%= simple_form_for experience, url: experience.persisted? ? experience_path(experience) : experiences_path do |f| %>
<% if experience.errors.any? %>
<div id="error_explanation" class="text-danger">
<ul class="list-unstyled">
<% experience.errors.each do |error| %>
<li><%= error.full_message %></li>
<% end %>
</ul>
</div>
<% end %>
<div class="row">
<div class="col-lg-6">
<%= f.input :description, as: :string %>
......@@ -26,6 +16,7 @@
<%= f.input :organization_name,
label: University::Organization.model_name.human,
as: :autocomplete,
required: true,
url: search_organizations_path,
placeholder: t("extranet.experiences.search_organization"),
input_html: {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment