Skip to content

Commit

Permalink
TG-45 #ready-for-test
Browse files Browse the repository at this point in the history
  • Loading branch information
igkyab committed Jul 29, 2016
1 parent cc55fac commit 33df74f
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 6 deletions.
4 changes: 2 additions & 2 deletions app/models/activity.rb
Expand Up @@ -131,8 +131,8 @@ class Activity < Ekylibre::Record::Base
accepts_nested_attributes_for :distributions, reject_if: :all_blank, allow_destroy: true
accepts_nested_attributes_for :inspection_point_natures, allow_destroy: true
accepts_nested_attributes_for :inspection_calibration_scales, allow_destroy: true
accepts_nested_attributes_for :seasons, update_only: true, reject_if: -> (par) { par[:name].blank? }
accepts_nested_attributes_for :tactics, update_only: true, allow_destroy: true, reject_if: :all_blank
accepts_nested_attributes_for :seasons, allow_destroy: true, reject_if: -> (par) { par[:name].blank? }
accepts_nested_attributes_for :tactics, allow_destroy: true, reject_if: :all_blank
accepts_nested_attributes_for :plant_density_abaci, allow_destroy: true, reject_if: :all_blank
# protect(on: :update) do
# productions.any?
Expand Down
6 changes: 4 additions & 2 deletions app/models/activity_season.rb
Expand Up @@ -33,11 +33,13 @@
#
class ActivitySeason < Ekylibre::Record::Base
belongs_to :activity, class_name: 'Activity', inverse_of: :seasons
has_many :productions, class_name: 'ActivityProduction', inverse_of: :activity_season
has_many :productions, class_name: 'ActivityProduction', inverse_of: :season, foreign_key: :season_id

# [VALIDATORS[ Do not edit these lines directly. Use `rake clean:validations`.
validates :activity, presence: true
# ]VALIDATORS]


protect(on: :destroy) do
productions.any?
end
end
1 change: 0 additions & 1 deletion app/models/activity_tactic.rb
Expand Up @@ -54,5 +54,4 @@ class ActivityTactic < Ekylibre::Record::Base
protect(on: :destroy) do
productions.any?
end

end
2 changes: 1 addition & 1 deletion app/views/backend/activities/_season_fields.html.haml
@@ -1,3 +1,3 @@
.nested-fields
= link_to_remove_nested_association(:seasons, f)
= link_to_remove_nested_association(:seasons, f) if f.object.destroyable?
= f.input :name

0 comments on commit 33df74f

Please sign in to comment.