mirror of
https://github.com/openSUSE/osem.git
synced 2026-08-13 19:54:02 +00:00
Merge pull request #1148 from Ana06/event-schedule-validation
Validation in EventSchedule
This commit is contained in:
commit
6c2dc92b84
3 changed files with 8 additions and 1 deletions
|
|
@ -7,6 +7,7 @@ class EventSchedule < ActiveRecord::Base
|
|||
validates :event, presence: true
|
||||
validates :room, presence: true
|
||||
validates :start_time, presence: true
|
||||
validates :event, uniqueness: { scope: :schedule }
|
||||
|
||||
scope :confirmed, -> { joins(:event).where('state = ?', 'confirmed') }
|
||||
scope :canceled, -> { joins(:event).where('state = ?', 'canceled') }
|
||||
|
|
|
|||
5
db/migrate/20160815140302_add_index_to_event_schedule.rb
Normal file
5
db/migrate/20160815140302_add_index_to_event_schedule.rb
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
class AddIndexToEventSchedule < ActiveRecord::Migration
|
||||
def change
|
||||
add_index :event_schedules, [:event_id, :schedule_id], unique: true
|
||||
end
|
||||
end
|
||||
|
|
@ -11,7 +11,7 @@
|
|||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(version: 20160704092023) do
|
||||
ActiveRecord::Schema.define(version: 20160815140302) do
|
||||
|
||||
create_table "ahoy_events", force: :cascade do |t|
|
||||
t.uuid "visit_id", limit: 16
|
||||
|
|
@ -185,6 +185,7 @@ ActiveRecord::Schema.define(version: 20160704092023) do
|
|||
t.datetime "updated_at", null: false
|
||||
end
|
||||
|
||||
add_index "event_schedules", ["event_id", "schedule_id"], name: "index_event_schedules_on_event_id_and_schedule_id", unique: true
|
||||
add_index "event_schedules", ["event_id"], name: "index_event_schedules_on_event_id"
|
||||
add_index "event_schedules", ["room_id"], name: "index_event_schedules_on_room_id"
|
||||
add_index "event_schedules", ["schedule_id"], name: "index_event_schedules_on_schedule_id"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue