File tree Expand file tree Collapse file tree 2 files changed +4
-4
lines changed Expand file tree Collapse file tree 2 files changed +4
-4
lines changed Original file line number Diff line number Diff line change @@ -48,9 +48,9 @@ def create
4848 batch = params [ :weekday ] [ :batch_id ]
4949 if request . post?
5050 new_weekdays = params [ :weekdays ] ||[ ]
51- batch = params [ :weekday ] [ :batch_id ] . empty? ? nil : params [ :weekday ] [ :batch_id ]
51+ batch = params [ :weekday ] [ :batch_id ] . present? ? params [ :weekday ] [ :batch_id ] : nil
5252 old = Weekday . find ( :all , :conditions => { :batch_id => batch , :is_deleted => false } )
53- batch_id = params [ :weekday ] [ :batch_id ] . empty? ? 0 : params [ :weekday ] [ :batch_id ]
53+ batch_id = params [ :weekday ] [ :batch_id ] . present? ? params [ :weekday ] [ :batch_id ] : 0
5454 old_weekdays = old . map { |w | w . weekday }
5555 flash [ :notice ] = ""
5656 ( new_weekdays -old_weekdays ) . each do |new |
Original file line number Diff line number Diff line change @@ -49,8 +49,8 @@ def self.add_day(batch_id,day)
4949 w . save
5050 end
5151 else
52- unless Weekday . find_by_day_of_week ( day ) . nil?
53- Weekday . find_by_day_of_week ( day ) . update_attributes ( :is_deleted => false , :day_of_week => day )
52+ unless Weekday . find_by_batch_id_and_day_of_week ( nil , day ) . nil?
53+ Weekday . find_by_batch_id_and_day_of_week ( nil , day ) . update_attributes ( :is_deleted => false , :day_of_week => day )
5454 else
5555 w = Weekday . new
5656 w . day_of_week = day
You can’t perform that action at this time.
0 commit comments