From 167030f90d5490c53b1ecffa0a0331e274252b3d Mon Sep 17 00:00:00 2001 From: Petko Bordjukov Date: Thu, 20 Aug 2015 00:33:13 +0300 Subject: [PATCH] Specify correct default values for events --- app/models/event.rb | 4 ++++ ...20150819213202_drop_default_value_for_length_in_events.rb | 5 +++++ 2 files changed, 9 insertions(+) create mode 100644 db/migrate/20150819213202_drop_default_value_for_length_in_events.rb diff --git a/app/models/event.rb b/app/models/event.rb index ecf9973..2d86869 100644 --- a/app/models/event.rb +++ b/app/models/event.rb @@ -29,6 +29,10 @@ class Event < ActiveRecord::Base proposer.personal_profile(conference) end + def length + read_attribute(:length) || event_type.try(:minimum_length) + end + private def track_belongs_to_the_selected_conference diff --git a/db/migrate/20150819213202_drop_default_value_for_length_in_events.rb b/db/migrate/20150819213202_drop_default_value_for_length_in_events.rb new file mode 100644 index 0000000..df70401 --- /dev/null +++ b/db/migrate/20150819213202_drop_default_value_for_length_in_events.rb @@ -0,0 +1,5 @@ +class DropDefaultValueForLengthInEvents < ActiveRecord::Migration + def change + change_column_default(:events, :length, nil) + end +end