Fix with migration bad table value for nil table attr

This commit is contained in:
Xavier J 2016-09-27 17:53:46 +02:00
parent b3d454a53b
commit 5ff37a270e
6 changed files with 16 additions and 7 deletions

View file

@ -8,7 +8,7 @@ class Backoffice::PreferenceListDossierController < ApplicationController
def add def add
PreferenceListDossier.create( PreferenceListDossier.create(
libelle: params[:libelle], libelle: params[:libelle],
table: params[:table], table: (params[:table].empty? ? nil : params[:table]),
attr: params[:attr], attr: params[:attr],
attr_decorate: params[:attr_decorate], attr_decorate: params[:attr_decorate],
bootstrap_lg: params[:bootstrap_lg], bootstrap_lg: params[:bootstrap_lg],

View file

@ -76,7 +76,7 @@ class DossiersListGestionnaireService
@current_devise_profil.preference_list_dossiers @current_devise_profil.preference_list_dossiers
.find_by(table: table, attr: attr, procedure: @procedure) .find_by(table: table, attr: attr, procedure: @procedure)
.update_column :order, order .update order: order
end end
def reset_sort! def reset_sort!

View file

@ -0,0 +1,9 @@
class ChangeEmptytoNilInPreferenceListDossierTable < ActiveRecord::Migration
class PreferenceListDossier < ActiveRecord::Base
end
def change
PreferenceListDossier.where(table: '').update_all table: nil
end
end

View file

@ -11,7 +11,7 @@
# #
# It's strongly recommended that you check this file into your version control system. # It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 20160926160051) do ActiveRecord::Schema.define(version: 20160927154248) do
# These are extensions that must be enabled in order to support this database # These are extensions that must be enabled in order to support this database
enable_extension "plpgsql" enable_extension "plpgsql"

View file

@ -12,13 +12,13 @@ describe DossiersListFacades do
create :preference_list_dossier, create :preference_list_dossier,
gestionnaire: gestionnaire, gestionnaire: gestionnaire,
table: '', table: nil,
attr: 'state', attr: 'state',
attr_decorate: 'display_state' attr_decorate: 'display_state'
create :preference_list_dossier, create :preference_list_dossier,
gestionnaire: gestionnaire, gestionnaire: gestionnaire,
table: '', table: nil,
attr: 'state', attr: 'state',
attr_decorate: 'display_state', attr_decorate: 'display_state',
procedure_id: procedure.id procedure_id: procedure.id

View file

@ -28,7 +28,7 @@ describe 'backoffice/dossiers/index.html.haml', type: :view do
create :preference_list_dossier, create :preference_list_dossier,
gestionnaire: gestionnaire, gestionnaire: gestionnaire,
table: '', table: nil,
attr: 'state', attr: 'state',
attr_decorate: 'display_state' attr_decorate: 'display_state'
@ -46,7 +46,7 @@ describe 'backoffice/dossiers/index.html.haml', type: :view do
create :preference_list_dossier, create :preference_list_dossier,
gestionnaire: gestionnaire, gestionnaire: gestionnaire,
table: '', table: nil,
attr: 'last_update', attr: 'last_update',
attr_decorate: 'last_update' attr_decorate: 'last_update'