Sha256: 65ae4b7cba33668c716b3675e267132559a5aa7d203fc8e88a8c254b3979eefd

Contents?: true

Size: 702 Bytes

Versions: 5

Compression:

Stored size: 702 Bytes

Contents

class FestivityPerformance < ActiveRecord::Base
  validates_presence_of :event_page_id
  belongs_to :festivity_event_page, foreign_key: :event_page_id
  belongs_to :festivity_location_page, foreign_key: :location_page_id
  default_scope {order :start_date}

  attr_accessible :start_date, :end_date, :festivity_location_page, :notes

  def start_date=(date)
    super(parse_date(date))
  end

  def end_date=(date)
    super(parse_date(date))
  end

  def festivity_location_page=(location)
    super(FestivityLocationPage.find(location[:id])) unless location[:id].blank?
  end

  private

  def parse_date(date)
    Time.parse(Time.strptime(date, "%m/%d/%Y %l:%M %P").to_s)
  rescue
    nil
  end

end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
trusty-festivity-extension-2.2.4 app/models/festivity_performance.rb
trusty-festivity-extension-2.2.3 app/models/festivity_performance.rb
trusty-festivity-extension-2.2.2 app/models/festivity_performance.rb
trusty-festivity-extension-2.2.1 app/models/festivity_performance.rb
trusty-festivity-extension-2.2.0 app/models/festivity_performance.rb