Link user and administrateur

This commit is contained in:
simon lehericey 2019-08-09 09:45:11 +02:00
parent 8082751912
commit 81f44fa76b
4 changed files with 13 additions and 1 deletions

View file

@ -12,6 +12,8 @@ class Administrateur < ApplicationRecord
has_many :services
has_many :dossiers, -> { state_not_brouillon }, through: :procedures
has_one :user
before_validation -> { sanitize_email(:email) }
scope :inactive, -> { where(active: false) }

View file

@ -18,6 +18,7 @@ class User < ApplicationRecord
has_many :feedbacks, dependent: :destroy
has_one :france_connect_information, dependent: :destroy
belongs_to :instructeur
belongs_to :administrateur
accepts_nested_attributes_for :france_connect_information

View file

@ -0,0 +1,6 @@
class LinkUserAndAdministrateur < ActiveRecord::Migration[5.2]
def change
add_reference :users, :administrateur, index: true
add_foreign_key :users, :administrateurs
end
end

View file

@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 2019_08_08_144607) do
ActiveRecord::Schema.define(version: 2019_08_09_073736) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
@ -597,6 +597,8 @@ ActiveRecord::Schema.define(version: 2019_08_08_144607) do
t.datetime "locked_at"
t.text "unconfirmed_email"
t.bigint "instructeur_id"
t.bigint "administrateur_id"
t.index ["administrateur_id"], name: "index_users_on_administrateur_id"
t.index ["confirmation_token"], name: "index_users_on_confirmation_token", unique: true
t.index ["email"], name: "index_users_on_email", unique: true
t.index ["instructeur_id"], name: "index_users_on_instructeur_id"
@ -644,6 +646,7 @@ ActiveRecord::Schema.define(version: 2019_08_08_144607) do
add_foreign_key "services", "administrateurs"
add_foreign_key "trusted_device_tokens", "instructeurs"
add_foreign_key "types_de_champ", "types_de_champ", column: "parent_id"
add_foreign_key "users", "administrateurs"
add_foreign_key "users", "instructeurs"
add_foreign_key "without_continuation_mails", "procedures"
end