Create new model Avis

This commit is contained in:
Mathieu Magnin 2017-04-25 12:09:11 +02:00 committed by Simon Lehericey
parent 3e0977d56f
commit 72494de76f
6 changed files with 34 additions and 1 deletions

4
app/models/avis.rb Normal file
View file

@ -0,0 +1,4 @@
class Avis < ApplicationRecord
belongs_to :dossier
belongs_to :gestionnaire
end

View file

@ -25,6 +25,7 @@ class Dossier < ActiveRecord::Base
has_many :invites_gestionnaires, class_name: 'InviteGestionnaire', dependent: :destroy
has_many :follows
has_many :notifications, dependent: :destroy
has_many :avis, dependent: :destroy
belongs_to :procedure
belongs_to :user

View file

@ -12,6 +12,7 @@ class Gestionnaire < ActiveRecord::Base
has_many :followed_dossiers, through: :follows, source: :dossier
has_many :follows
has_many :preference_list_dossiers
has_many :avis
after_create :build_default_preferences_list_dossier
after_create :build_default_preferences_smart_listing_page

View file

@ -15,6 +15,7 @@ ActiveSupport::Inflector.inflections(:en) do |inflect|
inflect.irregular 'type_de_champ', 'types_de_champ'
inflect.irregular 'type_de_champ_private', 'types_de_champ_private'
inflect.irregular 'assign_to', 'assign_tos'
inflect.irregular('avis', 'avis')
end
# These inflection rules are supported but not enabled by default:
@ -24,4 +25,5 @@ end
ActiveSupport::Inflector.inflections(:fr) do |inflect|
inflect.plural(/$/, 's')
inflect.plural(/(hib|ch|bij|caill|p|gen|jouj)ou$/i, '\1oux')
inflect.irregular('avis', 'avis')
end

View file

@ -0,0 +1,13 @@
class CreateAvis < ActiveRecord::Migration[5.0]
def change
create_table :avis do |t|
t.string :email
t.text :introduction
t.text :answer
t.references :gestionnaire
t.references :dossier
t.timestamps
end
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: 20170523081220) do
ActiveRecord::Schema.define(version: 20170425100757) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
@ -71,6 +71,18 @@ ActiveRecord::Schema.define(version: 20170523081220) do
t.index ["procedure_id"], name: "index_assign_tos_on_procedure_id", using: :btree
end
create_table "avis", force: :cascade do |t|
t.string "email"
t.text "introduction"
t.text "answer"
t.integer "gestionnaire_id"
t.integer "dossier_id"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["dossier_id"], name: "index_avis_on_dossier_id", using: :btree
t.index ["gestionnaire_id"], name: "index_avis_on_gestionnaire_id", using: :btree
end
create_table "cadastres", force: :cascade do |t|
t.string "surface_intersection"
t.float "surface_parcelle"