From 4ca49d6136402529a1048bbc214318cb9a1fa242 Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Thu, 22 Aug 2013 23:15:23 +0200 Subject: [PATCH] Moved to rails4. --- app/models/application_model.rb | 12 +++++++----- config/application.rb | 6 ------ config/environments/test_mysql.rb | 3 --- 3 files changed, 7 insertions(+), 14 deletions(-) diff --git a/app/models/application_model.rb b/app/models/application_model.rb index b591d47f8..663e6ba58 100644 --- a/app/models/application_model.rb +++ b/app/models/application_model.rb @@ -7,6 +7,7 @@ require 'sessions' class ApplicationModel < ActiveRecord::Base self.abstract_class = true + before_create :check_attributes_protected, :cache_delete, :fill_up_user_create before_create :cache_delete, :fill_up_user_create before_update :cache_delete_before, :fill_up_user_update before_destroy :cache_delete_before @@ -16,12 +17,11 @@ class ApplicationModel < ActiveRecord::Base @@import_class_list = ['Ticket', 'Ticket::Article', 'History', 'Ticket::State', 'Ticket::Priority', 'Group', 'User' ] - # for import of other objects, remove 'id' - def self.attributes_protected_by_default + def check_attributes_protected if Setting.get('import_mode') && @@import_class_list.include?( self.name.to_s ) - ['type'] + # do noting, use id as it is else - ['id','type'] + self[:id] = nil end end @@ -71,7 +71,9 @@ returns data.delete( :created_at ) data.delete( :updated_by_id ) data.delete( :created_by_id ) - + if data.respond_to?('permit!') + data.permit! + end data end diff --git a/config/application.rb b/config/application.rb index 9e9c33930..dcbe54f32 100644 --- a/config/application.rb +++ b/config/application.rb @@ -61,12 +61,6 @@ module Zammad # like if you have constraints or database-specific column types # config.active_record.schema_format = :sql - # Enforce whitelist mode for mass assignment. - # This will create an empty whitelist of attributes available for mass-assignment for all models - # in your app. As such, your models will need to explicitly whitelist or blacklist accessible - # parameters by using an attr_accessible or attr_protected declaration. - # config.active_record.whitelist_attributes = true - # Enable the asset pipeline config.assets.enabled = true diff --git a/config/environments/test_mysql.rb b/config/environments/test_mysql.rb index f3e3b8f66..8e7ee2ef8 100644 --- a/config/environments/test_mysql.rb +++ b/config/environments/test_mysql.rb @@ -15,9 +15,6 @@ Zammad::Application.configure do config.assets.compile = true config.assets.digest = true - # Log error messages when you accidentally call methods on nil - config.whiny_nils = true - # Show full error reports and disable caching config.consider_all_requests_local = true config.action_controller.perform_caching = true