diff --git a/app/mailers/mailing.rb b/app/mailers/mailing.rb
index 08d844c..c680c5a 100644
--- a/app/mailers/mailing.rb
+++ b/app/mailers/mailing.rb
@@ -1,6 +1,6 @@
require_dependency 'mailing_job'
-class Mailing < ActiveRecord::Base
+class Mailing < ApplicationRecord
acts_as_having_settings :field => :data
diff --git a/app/models/abuse_report.rb b/app/models/abuse_report.rb
index 73f99fe..d641b68 100644
--- a/app/models/abuse_report.rb
+++ b/app/models/abuse_report.rb
@@ -1,4 +1,4 @@
-class AbuseReport < ActiveRecord::Base
+class AbuseReport < ApplicationRecord
belongs_to :reporter, :class_name => 'Person'
belongs_to :abuse_complaint
diff --git a/app/models/action_tracker_notification.rb b/app/models/action_tracker_notification.rb
index b8ef0cc..3c62927 100644
--- a/app/models/action_tracker_notification.rb
+++ b/app/models/action_tracker_notification.rb
@@ -1,4 +1,4 @@
-class ActionTrackerNotification < ActiveRecord::Base
+class ActionTrackerNotification < ApplicationRecord
belongs_to :profile
belongs_to :action_tracker, :class_name => 'ActionTracker::Record', :foreign_key => 'action_tracker_id'
diff --git a/app/models/application_record.rb b/app/models/application_record.rb
new file mode 100644
index 0000000..06e635a
--- /dev/null
+++ b/app/models/application_record.rb
@@ -0,0 +1,64 @@
+class ApplicationRecord < ActiveRecord::Base
+
+ self.abstract_class = true
+
+ def self.postgresql?
+ ActiveRecord::Base.connection.adapter_name == 'PostgreSQL'
+ end
+
+ # an ActionView instance for rendering views on models
+ def self.action_view
+ @action_view ||= begin
+ view_paths = ::ActionController::Base.view_paths
+ action_view = ::ActionView::Base.new view_paths
+ # for using Noosfero helpers inside render calls
+ action_view.extend ::ApplicationHelper
+ action_view
+ end
+ end
+
+ # default value needed for the above ActionView
+ def to_partial_path
+ self.class.name.underscore
+ end
+
+ alias :meta_cache_key :cache_key
+ def cache_key
+ key = [Noosfero::VERSION, meta_cache_key]
+ key.unshift(ActiveRecord::Base.connection.schema_search_path) if ActiveRecord::Base.postgresql?
+ key.join('/')
+ end
+
+ def self.like_search(query, options={})
+ if defined?(self::SEARCHABLE_FIELDS) || options[:fields].present?
+ fields_per_table = {}
+ fields_per_table[table_name] = (options[:fields].present? ? options[:fields] : self::SEARCHABLE_FIELDS.keys.map(&:to_s)) & column_names
+
+ if options[:joins].present?
+ join_asset = options[:joins].to_s.classify.constantize
+ if defined?(join_asset::SEARCHABLE_FIELDS) || options[:fields].present?
+ fields_per_table[join_asset.table_name] = (options[:fields].present? ? options[:fields] : join_asset::SEARCHABLE_FIELDS.keys.map(&:to_s)) & join_asset.column_names
+ end
+ end
+
+ query = query.downcase.strip
+ fields_per_table.delete_if { |table,fields| fields.blank? }
+ conditions = fields_per_table.map do |table,fields|
+ fields.map do |field|
+ "lower(#{table}.#{field}) LIKE '%#{query}%'"
+ end.join(' OR ')
+ end.join(' OR ')
+
+ if options[:joins].present?
+ joins(options[:joins]).where(conditions)
+ else
+ where(conditions)
+ end
+
+ else
+ raise "No searchable fields defined for #{self.name}"
+ end
+ end
+
+end
+
diff --git a/app/models/article.rb b/app/models/article.rb
index 4b32cef..e3da8e2 100644
--- a/app/models/article.rb
+++ b/app/models/article.rb
@@ -1,5 +1,5 @@
-class Article < ActiveRecord::Base
+class Article < ApplicationRecord
acts_as_having_image
include Noosfero::Plugin::HotSpot
diff --git a/app/models/article_categorization.rb b/app/models/article_categorization.rb
index f86c2eb..1925eca 100644
--- a/app/models/article_categorization.rb
+++ b/app/models/article_categorization.rb
@@ -1,4 +1,4 @@
-class ArticleCategorization < ActiveRecord::Base
+class ArticleCategorization < ApplicationRecord
self.table_name = :articles_categories
belongs_to :article
diff --git a/app/models/block.rb b/app/models/block.rb
index 7fe2791..46fdcb7 100644
--- a/app/models/block.rb
+++ b/app/models/block.rb
@@ -1,4 +1,4 @@
-class Block < ActiveRecord::Base
+class Block < ApplicationRecord
include ActionView::Helpers::TagHelper
diff --git a/app/models/box.rb b/app/models/box.rb
index ed5ff2f..c4aa60a 100644
--- a/app/models/box.rb
+++ b/app/models/box.rb
@@ -1,4 +1,4 @@
-class Box < ActiveRecord::Base
+class Box < ApplicationRecord
acts_as_list scope: -> box { where owner_id: box.owner_id, owner_type: box.owner_type }
diff --git a/app/models/category.rb b/app/models/category.rb
index 226942b..81b4f2a 100644
--- a/app/models/category.rb
+++ b/app/models/category.rb
@@ -1,4 +1,4 @@
-class Category < ActiveRecord::Base
+class Category < ApplicationRecord
SEARCHABLE_FIELDS = {
:name => {:label => _('Name'), :weight => 10},
diff --git a/app/models/certifier.rb b/app/models/certifier.rb
index 79f9061..b99cce6 100644
--- a/app/models/certifier.rb
+++ b/app/models/certifier.rb
@@ -1,4 +1,4 @@
-class Certifier < ActiveRecord::Base
+class Certifier < ApplicationRecord
SEARCHABLE_FIELDS = {
:name => {:label => _('Name'), :weight => 10},
diff --git a/app/models/chat_message.rb b/app/models/chat_message.rb
index 0ef3948..ca9d1fa 100644
--- a/app/models/chat_message.rb
+++ b/app/models/chat_message.rb
@@ -1,4 +1,4 @@
-class ChatMessage < ActiveRecord::Base
+class ChatMessage < ApplicationRecord
belongs_to :to, :class_name => 'Profile'
belongs_to :from, :class_name => 'Profile'
diff --git a/app/models/comment.rb b/app/models/comment.rb
index e6a993c..b747db7 100644
--- a/app/models/comment.rb
+++ b/app/models/comment.rb
@@ -1,4 +1,4 @@
-class Comment < ActiveRecord::Base
+class Comment < ApplicationRecord
SEARCHABLE_FIELDS = {
:title => {:label => _('Title'), :weight => 10},
diff --git a/app/models/contact_list.rb b/app/models/contact_list.rb
index 54ccf59..bb772ba 100644
--- a/app/models/contact_list.rb
+++ b/app/models/contact_list.rb
@@ -1,4 +1,4 @@
-class ContactList < ActiveRecord::Base
+class ContactList < ApplicationRecord
serialize :list, Array
diff --git a/app/models/custom_field.rb b/app/models/custom_field.rb
index f46512d..80ffe53 100644
--- a/app/models/custom_field.rb
+++ b/app/models/custom_field.rb
@@ -1,4 +1,4 @@
-class CustomField < ActiveRecord::Base
+class CustomField < ApplicationRecord
serialize :customized_type
serialize :extras
diff --git a/app/models/custom_field_value.rb b/app/models/custom_field_value.rb
index a04cada..0981c21 100644
--- a/app/models/custom_field_value.rb
+++ b/app/models/custom_field_value.rb
@@ -1,4 +1,4 @@
-class CustomFieldValue < ActiveRecord::Base
+class CustomFieldValue < ApplicationRecord
belongs_to :custom_field
belongs_to :customized, :polymorphic => true
diff --git a/app/models/domain.rb b/app/models/domain.rb
index 364a7f9..baacdeb 100644
--- a/app/models/domain.rb
+++ b/app/models/domain.rb
@@ -1,6 +1,6 @@
require 'noosfero/multi_tenancy'
-class Domain < ActiveRecord::Base
+class Domain < ApplicationRecord
# relationships
###############
diff --git a/app/models/environment.rb b/app/models/environment.rb
index 1099029..ce3f677 100644
--- a/app/models/environment.rb
+++ b/app/models/environment.rb
@@ -1,7 +1,7 @@
# A Environment is like a website to be hosted in the platform. It may
# contain multiple Profile's and can be identified by several different
# domains.
-class Environment < ActiveRecord::Base
+class Environment < ApplicationRecord
has_many :users
diff --git a/app/models/external_feed.rb b/app/models/external_feed.rb
index 7e04b15..50a72ed 100644
--- a/app/models/external_feed.rb
+++ b/app/models/external_feed.rb
@@ -1,4 +1,4 @@
-class ExternalFeed < ActiveRecord::Base
+class ExternalFeed < ApplicationRecord
belongs_to :blog
validates_presence_of :blog_id
diff --git a/app/models/favorite_enterprise_person.rb b/app/models/favorite_enterprise_person.rb
index 4ad111b..a16b47a 100644
--- a/app/models/favorite_enterprise_person.rb
+++ b/app/models/favorite_enterprise_person.rb
@@ -1,4 +1,4 @@
-class FavoriteEnterprisePerson < ActiveRecord::Base
+class FavoriteEnterprisePerson < ApplicationRecord
track_actions :favorite_enterprise, :after_create, keep_params: [:enterprise_name, :enterprise_url], if: proc{ |f| f.is_trackable? }
diff --git a/app/models/friendship.rb b/app/models/friendship.rb
index d7d2e9f..c497b1b 100644
--- a/app/models/friendship.rb
+++ b/app/models/friendship.rb
@@ -1,4 +1,4 @@
-class Friendship < ActiveRecord::Base
+class Friendship < ApplicationRecord
track_actions :new_friendship, :after_create, :keep_params => ["friend.name", "friend.url", "friend.profile_custom_icon"], :custom_user => :person
extend CacheCounterHelper
diff --git a/app/models/image.rb b/app/models/image.rb
index 4d08f50..c537339 100644
--- a/app/models/image.rb
+++ b/app/models/image.rb
@@ -1,4 +1,4 @@
-class Image < ActiveRecord::Base
+class Image < ApplicationRecord
attr_accessor :remove_image
diff --git a/app/models/input.rb b/app/models/input.rb
index 12dfe8b..0b477d8 100644
--- a/app/models/input.rb
+++ b/app/models/input.rb
@@ -1,4 +1,4 @@
-class Input < ActiveRecord::Base
+class Input < ApplicationRecord
belongs_to :product
belongs_to :product_category
diff --git a/app/models/license.rb b/app/models/license.rb
index 4f1ddff..acd5287 100644
--- a/app/models/license.rb
+++ b/app/models/license.rb
@@ -1,4 +1,4 @@
-class License < ActiveRecord::Base
+class License < ApplicationRecord
SEARCHABLE_FIELDS = {
:name => {:label => _('Name'), :weight => 10},
diff --git a/app/models/mailing_sent.rb b/app/models/mailing_sent.rb
index 367dcfe..959b6f7 100644
--- a/app/models/mailing_sent.rb
+++ b/app/models/mailing_sent.rb
@@ -1,4 +1,4 @@
-class MailingSent < ActiveRecord::Base
+class MailingSent < ApplicationRecord
belongs_to :mailing
belongs_to :person
diff --git a/app/models/national_region.rb b/app/models/national_region.rb
index 703d997..0959b7e 100644
--- a/app/models/national_region.rb
+++ b/app/models/national_region.rb
@@ -1,4 +1,4 @@
-class NationalRegion < ActiveRecord::Base
+class NationalRegion < ApplicationRecord
SEARCHABLE_FIELDS = {
:name => {:label => _('Name'), :weight => 1},
diff --git a/app/models/national_region_type.rb b/app/models/national_region_type.rb
index ae3f1e6..d1f432b 100644
--- a/app/models/national_region_type.rb
+++ b/app/models/national_region_type.rb
@@ -1,4 +1,4 @@
-class NationalRegionType < ActiveRecord::Base
+class NationalRegionType < ApplicationRecord
COUNTRY = 1
STATE = 2
CITY = 3
diff --git a/app/models/price_detail.rb b/app/models/price_detail.rb
index 958c1a5..8fc1628 100644
--- a/app/models/price_detail.rb
+++ b/app/models/price_detail.rb
@@ -1,4 +1,4 @@
-class PriceDetail < ActiveRecord::Base
+class PriceDetail < ApplicationRecord
belongs_to :product
validates_presence_of :product_id
diff --git a/app/models/product.rb b/app/models/product.rb
index 42e8686..3ea3a02 100644
--- a/app/models/product.rb
+++ b/app/models/product.rb
@@ -1,4 +1,4 @@
-class Product < ActiveRecord::Base
+class Product < ApplicationRecord
SEARCHABLE_FIELDS = {
:name => {:label => _('Name'), :weight => 10},
diff --git a/app/models/product_qualifier.rb b/app/models/product_qualifier.rb
index 69ebe1d..45f6bce 100644
--- a/app/models/product_qualifier.rb
+++ b/app/models/product_qualifier.rb
@@ -1,4 +1,4 @@
-class ProductQualifier < ActiveRecord::Base
+class ProductQualifier < ApplicationRecord
belongs_to :qualifier
belongs_to :product
diff --git a/app/models/production_cost.rb b/app/models/production_cost.rb
index 0f80cdc..e065077 100644
--- a/app/models/production_cost.rb
+++ b/app/models/production_cost.rb
@@ -1,4 +1,4 @@
-class ProductionCost < ActiveRecord::Base
+class ProductionCost < ApplicationRecord
belongs_to :owner, :polymorphic => true
diff --git a/app/models/profile.rb b/app/models/profile.rb
index 93f285e..ca840b4 100644
--- a/app/models/profile.rb
+++ b/app/models/profile.rb
@@ -1,7 +1,7 @@
# A Profile is the representation and web-presence of an individual or an
# organization. Every Profile is attached to its Environment of origin,
# which by default is the one returned by Environment:default.
-class Profile < ActiveRecord::Base
+class Profile < ApplicationRecord
# use for internationalizable human type names in search facets
# reimplement on subclasses
diff --git a/app/models/profile_activity.rb b/app/models/profile_activity.rb
index ee45be7..9321430 100644
--- a/app/models/profile_activity.rb
+++ b/app/models/profile_activity.rb
@@ -1,4 +1,4 @@
-class ProfileActivity < ActiveRecord::Base
+class ProfileActivity < ApplicationRecord
self.record_timestamps = false
diff --git a/app/models/profile_categorization.rb b/app/models/profile_categorization.rb
index 5d689bf..5a76827 100644
--- a/app/models/profile_categorization.rb
+++ b/app/models/profile_categorization.rb
@@ -1,4 +1,4 @@
-class ProfileCategorization < ActiveRecord::Base
+class ProfileCategorization < ApplicationRecord
self.table_name = :categories_profiles
belongs_to :profile
belongs_to :category
diff --git a/app/models/profile_suggestion.rb b/app/models/profile_suggestion.rb
index e0fd18f..3948729 100644
--- a/app/models/profile_suggestion.rb
+++ b/app/models/profile_suggestion.rb
@@ -1,4 +1,4 @@
-class ProfileSuggestion < ActiveRecord::Base
+class ProfileSuggestion < ApplicationRecord
belongs_to :person
belongs_to :suggestion, :class_name => 'Profile', :foreign_key => :suggestion_id
diff --git a/app/models/qualifier.rb b/app/models/qualifier.rb
index 03777b9..26cee30 100644
--- a/app/models/qualifier.rb
+++ b/app/models/qualifier.rb
@@ -1,4 +1,4 @@
-class Qualifier < ActiveRecord::Base
+class Qualifier < ApplicationRecord
SEARCHABLE_FIELDS = {
:name => {:label => _('Name'), :weight => 1},
diff --git a/app/models/qualifier_certifier.rb b/app/models/qualifier_certifier.rb
index e58d6aa..7aaa984 100644
--- a/app/models/qualifier_certifier.rb
+++ b/app/models/qualifier_certifier.rb
@@ -1,4 +1,4 @@
-class QualifierCertifier < ActiveRecord::Base
+class QualifierCertifier < ApplicationRecord
belongs_to :qualifier
belongs_to :certifier
diff --git a/app/models/reported_image.rb b/app/models/reported_image.rb
index e0f978b..69aacba 100644
--- a/app/models/reported_image.rb
+++ b/app/models/reported_image.rb
@@ -1,4 +1,4 @@
-class ReportedImage < ActiveRecord::Base
+class ReportedImage < ApplicationRecord
belongs_to :abuse_report
validates_presence_of :abuse_report
diff --git a/app/models/scrap.rb b/app/models/scrap.rb
index bfb25a1..eb89670 100644
--- a/app/models/scrap.rb
+++ b/app/models/scrap.rb
@@ -1,4 +1,4 @@
-class Scrap < ActiveRecord::Base
+class Scrap < ApplicationRecord
SEARCHABLE_FIELDS = {
:content => {:label => _('Content'), :weight => 1},
diff --git a/app/models/search_term.rb b/app/models/search_term.rb
index ae0813e..09a6a3f 100644
--- a/app/models/search_term.rb
+++ b/app/models/search_term.rb
@@ -1,4 +1,4 @@
-class SearchTerm < ActiveRecord::Base
+class SearchTerm < ApplicationRecord
validates_presence_of :term, :context
validates_uniqueness_of :term, :scope => [:context_id, :context_type, :asset]
diff --git a/app/models/search_term_occurrence.rb b/app/models/search_term_occurrence.rb
index 29208f2..c43ed02 100644
--- a/app/models/search_term_occurrence.rb
+++ b/app/models/search_term_occurrence.rb
@@ -1,4 +1,4 @@
-class SearchTermOccurrence < ActiveRecord::Base
+class SearchTermOccurrence < ApplicationRecord
belongs_to :search_term
validates_presence_of :search_term
diff --git a/app/models/suggestion_connection.rb b/app/models/suggestion_connection.rb
index 9af9b71..9acd072 100644
--- a/app/models/suggestion_connection.rb
+++ b/app/models/suggestion_connection.rb
@@ -1,4 +1,4 @@
-class SuggestionConnection < ActiveRecord::Base
+class SuggestionConnection < ApplicationRecord
belongs_to :suggestion, :class_name => 'ProfileSuggestion', :foreign_key => 'suggestion_id'
belongs_to :connection, :polymorphic => true
diff --git a/app/models/task.rb b/app/models/task.rb
index 4aa3e0a..0f56184 100644
--- a/app/models/task.rb
+++ b/app/models/task.rb
@@ -9,7 +9,7 @@
# This class has a +data+ field of type text, where you can store any
# type of data (as serialized Ruby objects) you need for your subclass (which
# will need to declare itself).
-class Task < ActiveRecord::Base
+class Task < ApplicationRecord
acts_as_having_settings :field => :data
diff --git a/app/models/thumbnail.rb b/app/models/thumbnail.rb
index 8186afa..13d5d05 100644
--- a/app/models/thumbnail.rb
+++ b/app/models/thumbnail.rb
@@ -1,4 +1,4 @@
-class Thumbnail < ActiveRecord::Base
+class Thumbnail < ApplicationRecord
has_attachment :storage => :file_system,
:content_type => :image, :max_size => UploadedFile.max_size, processor: 'Rmagick'
diff --git a/app/models/unit.rb b/app/models/unit.rb
index c393a1b..f161ba4 100644
--- a/app/models/unit.rb
+++ b/app/models/unit.rb
@@ -1,4 +1,4 @@
-class Unit < ActiveRecord::Base
+class Unit < ApplicationRecord
acts_as_list scope: -> unit { where environment_id: unit.environment_id }
diff --git a/app/models/user.rb b/app/models/user.rb
index af364f6..8da24f0 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -4,7 +4,7 @@ require 'securerandom'
# User models the system users, and is generated by the acts_as_authenticated
# Rails generator.
-class User < ActiveRecord::Base
+class User < ApplicationRecord
N_('Password')
N_('Password confirmation')
diff --git a/app/models/validation_info.rb b/app/models/validation_info.rb
index 275abaf..28c8705 100644
--- a/app/models/validation_info.rb
+++ b/app/models/validation_info.rb
@@ -1,4 +1,4 @@
-class ValidationInfo < ActiveRecord::Base
+class ValidationInfo < ApplicationRecord
belongs_to :organization
diff --git a/db/migrate/059_add_birth_date_to_person.rb b/db/migrate/059_add_birth_date_to_person.rb
index 57d615f..0c5234a 100644
--- a/db/migrate/059_add_birth_date_to_person.rb
+++ b/db/migrate/059_add_birth_date_to_person.rb
@@ -29,7 +29,7 @@ class AddBirthDateToPerson < ActiveRecord::Migration
end
end
- class Person < ActiveRecord::Base
+ class Person < ApplicationRecord
self.table_name = 'profiles'
serialize :data, Hash
end
diff --git a/db/migrate/069_add_enviroment_id_to_role.rb b/db/migrate/069_add_enviroment_id_to_role.rb
index 1989858..4d360d6 100644
--- a/db/migrate/069_add_enviroment_id_to_role.rb
+++ b/db/migrate/069_add_enviroment_id_to_role.rb
@@ -1,9 +1,9 @@
-class Role < ActiveRecord::Base; end
-class RoleWithEnvironment < ActiveRecord::Base
+class Role < ApplicationRecord
+class RoleWithEnvironment < ApplicationRecord
self.table_name = 'roles'
belongs_to :environment
end
-class RoleAssignment < ActiveRecord::Base
+class RoleAssignment < ApplicationRecord
belongs_to :accessor, :polymorphic => true
belongs_to :resource, :polymorphic => true
end
diff --git a/db/migrate/20110706171330_fix_misunderstood_script_filename.rb b/db/migrate/20110706171330_fix_misunderstood_script_filename.rb
index 78460d3..92d642b 100644
--- a/db/migrate/20110706171330_fix_misunderstood_script_filename.rb
+++ b/db/migrate/20110706171330_fix_misunderstood_script_filename.rb
@@ -2,7 +2,7 @@
# from the migration fall on a loop and breaks the migration. Both them are
# related to alias_method_chain, probably there is a problem with this kind of
# alias on the migration level.
-class Article < ActiveRecord::Base
+class Article < ApplicationRecord
def sanitize_tag_list
end
end
diff --git a/lib/noosfero/core_ext.rb b/lib/noosfero/core_ext.rb
index a935fa9..f9470c0 100644
--- a/lib/noosfero/core_ext.rb
+++ b/lib/noosfero/core_ext.rb
@@ -1,5 +1,5 @@
require 'noosfero/core_ext/string'
require 'noosfero/core_ext/integer'
-require 'noosfero/core_ext/active_record'
+require 'noosfero/core_ext/active_record/calculations'
require 'noosfero/core_ext/active_record/reflection'
diff --git a/lib/noosfero/core_ext/active_record.rb b/lib/noosfero/core_ext/active_record.rb
deleted file mode 100644
index 4370861..0000000
--- a/lib/noosfero/core_ext/active_record.rb
+++ /dev/null
@@ -1,74 +0,0 @@
-require 'active_record'
-
-class ActiveRecord::Base
-
- def self.postgresql?
- ActiveRecord::Base.connection.adapter_name == 'PostgreSQL'
- end
-
- # an ActionView instance for rendering views on models
- def self.action_view
- @action_view ||= begin
- view_paths = ::ActionController::Base.view_paths
- action_view = ::ActionView::Base.new view_paths
- # for using Noosfero helpers inside render calls
- action_view.extend ::ApplicationHelper
- action_view
- end
- end
-
- # default value needed for the above ActionView
- def to_partial_path
- self.class.name.underscore
- end
-
- alias :meta_cache_key :cache_key
- def cache_key
- key = [Noosfero::VERSION, meta_cache_key]
- key.unshift(ActiveRecord::Base.connection.schema_search_path) if ActiveRecord::Base.postgresql?
- key.join('/')
- end
-
- def self.like_search(query, options={})
- if defined?(self::SEARCHABLE_FIELDS) || options[:fields].present?
- fields_per_table = {}
- fields_per_table[table_name] = (options[:fields].present? ? options[:fields] : self::SEARCHABLE_FIELDS.keys.map(&:to_s)) & column_names
-
- if options[:joins].present?
- join_asset = options[:joins].to_s.classify.constantize
- if defined?(join_asset::SEARCHABLE_FIELDS) || options[:fields].present?
- fields_per_table[join_asset.table_name] = (options[:fields].present? ? options[:fields] : join_asset::SEARCHABLE_FIELDS.keys.map(&:to_s)) & join_asset.column_names
- end
- end
-
- query = query.downcase.strip
- fields_per_table.delete_if { |table,fields| fields.blank? }
- conditions = fields_per_table.map do |table,fields|
- fields.map do |field|
- "lower(#{table}.#{field}) LIKE '%#{query}%'"
- end.join(' OR ')
- end.join(' OR ')
-
- if options[:joins].present?
- joins(options[:joins]).where(conditions)
- else
- where(conditions)
- end
-
- else
- raise "No searchable fields defined for #{self.name}"
- end
- end
-
-end
-
-ActiveRecord::Calculations.class_eval do
- def count_with_distinct column_name=self.primary_key
- if column_name
- distinct.count_without_distinct column_name
- else
- count_without_distinct
- end
- end
- alias_method_chain :count, :distinct
-end
diff --git a/lib/noosfero/core_ext/active_record/calculations.rb b/lib/noosfero/core_ext/active_record/calculations.rb
new file mode 100644
index 0000000..cdaf434
--- /dev/null
+++ b/lib/noosfero/core_ext/active_record/calculations.rb
@@ -0,0 +1,10 @@
+ActiveRecord::Calculations.class_eval do
+ def count_with_distinct column_name=self.primary_key
+ if column_name
+ distinct.count_without_distinct column_name
+ else
+ count_without_distinct
+ end
+ end
+ alias_method_chain :count, :distinct
+end
diff --git a/plugins/analytics/models/analytics_plugin/page_view.rb b/plugins/analytics/models/analytics_plugin/page_view.rb
index d54512f..ad44fd5 100644
--- a/plugins/analytics/models/analytics_plugin/page_view.rb
+++ b/plugins/analytics/models/analytics_plugin/page_view.rb
@@ -1,4 +1,4 @@
-class AnalyticsPlugin::PageView < ActiveRecord::Base
+class AnalyticsPlugin::PageView < ApplicationRecord
serialize :data
diff --git a/plugins/analytics/models/analytics_plugin/visit.rb b/plugins/analytics/models/analytics_plugin/visit.rb
index 4405456..5628549 100644
--- a/plugins/analytics/models/analytics_plugin/visit.rb
+++ b/plugins/analytics/models/analytics_plugin/visit.rb
@@ -1,4 +1,4 @@
-class AnalyticsPlugin::Visit < ActiveRecord::Base
+class AnalyticsPlugin::Visit < ApplicationRecord
belongs_to :profile
has_many :page_views, class_name: 'AnalyticsPlugin::PageView', dependent: :destroy
diff --git a/plugins/comment_classification/lib/comment_classification_plugin/comment_label_user.rb b/plugins/comment_classification/lib/comment_classification_plugin/comment_label_user.rb
index a50595e..e3d03cf 100644
--- a/plugins/comment_classification/lib/comment_classification_plugin/comment_label_user.rb
+++ b/plugins/comment_classification/lib/comment_classification_plugin/comment_label_user.rb
@@ -1,4 +1,4 @@
-class CommentClassificationPlugin::CommentLabelUser < ActiveRecord::Base
+class CommentClassificationPlugin::CommentLabelUser < ApplicationRecord
self.table_name = :comment_classification_plugin_comment_label_user
belongs_to :profile
diff --git a/plugins/comment_classification/lib/comment_classification_plugin/comment_status_user.rb b/plugins/comment_classification/lib/comment_classification_plugin/comment_status_user.rb
index f63444c..5b55d31 100644
--- a/plugins/comment_classification/lib/comment_classification_plugin/comment_status_user.rb
+++ b/plugins/comment_classification/lib/comment_classification_plugin/comment_status_user.rb
@@ -1,4 +1,4 @@
-class CommentClassificationPlugin::CommentStatusUser < ActiveRecord::Base
+class CommentClassificationPlugin::CommentStatusUser < ApplicationRecord
self.table_name = :comment_classification_plugin_comment_status_user
belongs_to :profile
diff --git a/plugins/comment_classification/lib/comment_classification_plugin/label.rb b/plugins/comment_classification/lib/comment_classification_plugin/label.rb
index 048fd20..42fb226 100644
--- a/plugins/comment_classification/lib/comment_classification_plugin/label.rb
+++ b/plugins/comment_classification/lib/comment_classification_plugin/label.rb
@@ -1,4 +1,4 @@
-class CommentClassificationPlugin::Label < ActiveRecord::Base
+class CommentClassificationPlugin::Label < ApplicationRecord
belongs_to :owner, :polymorphic => true
diff --git a/plugins/comment_classification/lib/comment_classification_plugin/status.rb b/plugins/comment_classification/lib/comment_classification_plugin/status.rb
index 6ac78ed..53f2733 100644
--- a/plugins/comment_classification/lib/comment_classification_plugin/status.rb
+++ b/plugins/comment_classification/lib/comment_classification_plugin/status.rb
@@ -1,4 +1,4 @@
-class CommentClassificationPlugin::Status < ActiveRecord::Base
+class CommentClassificationPlugin::Status < ApplicationRecord
belongs_to :owner, :polymorphic => true
diff --git a/plugins/custom_forms/db/migrate/20130823151900_associate_fields_to_alternatives.rb b/plugins/custom_forms/db/migrate/20130823151900_associate_fields_to_alternatives.rb
index df6a986..acf8e51 100644
--- a/plugins/custom_forms/db/migrate/20130823151900_associate_fields_to_alternatives.rb
+++ b/plugins/custom_forms/db/migrate/20130823151900_associate_fields_to_alternatives.rb
@@ -1,5 +1,5 @@
class AssociateFieldsToAlternatives < ActiveRecord::Migration
- class CustomFormsPlugin::Field < ActiveRecord::Base
+ class CustomFormsPlugin::Field < ApplicationRecord
self.table_name = :custom_forms_plugin_fields
has_many :alternatives, :class_name => 'CustomFormsPlugin::Alternative'
serialize :choices, Hash
diff --git a/plugins/custom_forms/lib/custom_forms_plugin/alternative.rb b/plugins/custom_forms/lib/custom_forms_plugin/alternative.rb
index ff86bae..fc77f87 100644
--- a/plugins/custom_forms/lib/custom_forms_plugin/alternative.rb
+++ b/plugins/custom_forms/lib/custom_forms_plugin/alternative.rb
@@ -1,4 +1,4 @@
-class CustomFormsPlugin::Alternative < ActiveRecord::Base
+class CustomFormsPlugin::Alternative < ApplicationRecord
self.table_name = :custom_forms_plugin_alternatives
validates_presence_of :label
diff --git a/plugins/custom_forms/lib/custom_forms_plugin/answer.rb b/plugins/custom_forms/lib/custom_forms_plugin/answer.rb
index 6bcb080..1497dc2 100644
--- a/plugins/custom_forms/lib/custom_forms_plugin/answer.rb
+++ b/plugins/custom_forms/lib/custom_forms_plugin/answer.rb
@@ -1,4 +1,4 @@
-class CustomFormsPlugin::Answer < ActiveRecord::Base
+class CustomFormsPlugin::Answer < ApplicationRecord
self.table_name = :custom_forms_plugin_answers
belongs_to :field, :class_name => 'CustomFormsPlugin::Field'
belongs_to :submission, :class_name => 'CustomFormsPlugin::Submission'
diff --git a/plugins/custom_forms/lib/custom_forms_plugin/field.rb b/plugins/custom_forms/lib/custom_forms_plugin/field.rb
index 4577654..c88c04e 100644
--- a/plugins/custom_forms/lib/custom_forms_plugin/field.rb
+++ b/plugins/custom_forms/lib/custom_forms_plugin/field.rb
@@ -1,4 +1,4 @@
-class CustomFormsPlugin::Field < ActiveRecord::Base
+class CustomFormsPlugin::Field < ApplicationRecord
self.table_name = :custom_forms_plugin_fields
validates_presence_of :name
diff --git a/plugins/custom_forms/lib/custom_forms_plugin/form.rb b/plugins/custom_forms/lib/custom_forms_plugin/form.rb
index 1965b31..df71ad8 100644
--- a/plugins/custom_forms/lib/custom_forms_plugin/form.rb
+++ b/plugins/custom_forms/lib/custom_forms_plugin/form.rb
@@ -1,4 +1,4 @@
-class CustomFormsPlugin::Form < ActiveRecord::Base
+class CustomFormsPlugin::Form < ApplicationRecord
belongs_to :profile
diff --git a/plugins/custom_forms/lib/custom_forms_plugin/submission.rb b/plugins/custom_forms/lib/custom_forms_plugin/submission.rb
index a0fedd9..f0e1158 100644
--- a/plugins/custom_forms/lib/custom_forms_plugin/submission.rb
+++ b/plugins/custom_forms/lib/custom_forms_plugin/submission.rb
@@ -1,4 +1,4 @@
-class CustomFormsPlugin::Submission < ActiveRecord::Base
+class CustomFormsPlugin::Submission < ApplicationRecord
belongs_to :form, :class_name => 'CustomFormsPlugin::Form'
belongs_to :profile
diff --git a/plugins/delivery/models/delivery_plugin/method.rb b/plugins/delivery/models/delivery_plugin/method.rb
index 9d79f61..97eb4d8 100644
--- a/plugins/delivery/models/delivery_plugin/method.rb
+++ b/plugins/delivery/models/delivery_plugin/method.rb
@@ -1,4 +1,4 @@
-class DeliveryPlugin::Method < ActiveRecord::Base
+class DeliveryPlugin::Method < ApplicationRecord
Types = ['pickup', 'deliver']
diff --git a/plugins/delivery/models/delivery_plugin/option.rb b/plugins/delivery/models/delivery_plugin/option.rb
index 43d55a8..05e4fb3 100644
--- a/plugins/delivery/models/delivery_plugin/option.rb
+++ b/plugins/delivery/models/delivery_plugin/option.rb
@@ -1,4 +1,4 @@
-class DeliveryPlugin::Option < ActiveRecord::Base
+class DeliveryPlugin::Option < ApplicationRecord
belongs_to :delivery_method, :class_name => 'DeliveryPlugin::Method'
belongs_to :owner, :polymorphic => true
diff --git a/plugins/driven_signup/models/driven_signup_plugin/auth.rb b/plugins/driven_signup/models/driven_signup_plugin/auth.rb
index 2876c88..150c03f 100644
--- a/plugins/driven_signup/models/driven_signup_plugin/auth.rb
+++ b/plugins/driven_signup/models/driven_signup_plugin/auth.rb
@@ -1,4 +1,4 @@
-class DrivenSignupPlugin::Auth < ActiveRecord::Base
+class DrivenSignupPlugin::Auth < ApplicationRecord
belongs_to :environment
diff --git a/plugins/environment_notification/lib/environment_notifications_user.rb b/plugins/environment_notification/lib/environment_notifications_user.rb
index ec3c5df..d98e13d 100644
--- a/plugins/environment_notification/lib/environment_notifications_user.rb
+++ b/plugins/environment_notification/lib/environment_notifications_user.rb
@@ -1,4 +1,4 @@
-class EnvironmentNotificationsUser < ActiveRecord::Base
+class EnvironmentNotificationsUser < ApplicationRecord
self.table_name = "environment_notifications_users"
belongs_to :user
diff --git a/plugins/environment_notification/models/environment_notification_plugin/environment_notification.rb b/plugins/environment_notification/models/environment_notification_plugin/environment_notification.rb
index 6d27597..4cd876a 100644
--- a/plugins/environment_notification/models/environment_notification_plugin/environment_notification.rb
+++ b/plugins/environment_notification/models/environment_notification_plugin/environment_notification.rb
@@ -1,4 +1,4 @@
-class EnvironmentNotificationPlugin::EnvironmentNotification < ActiveRecord::Base
+class EnvironmentNotificationPlugin::EnvironmentNotification < ApplicationRecord
self.table_name = "environment_notifications"
diff --git a/plugins/fb_app/models/fb_app_plugin/page_tab.rb b/plugins/fb_app/models/fb_app_plugin/page_tab.rb
index 379b2f4..b96ae30 100644
--- a/plugins/fb_app/models/fb_app_plugin/page_tab.rb
+++ b/plugins/fb_app/models/fb_app_plugin/page_tab.rb
@@ -1,4 +1,4 @@
-class FbAppPlugin::PageTab < ActiveRecord::Base
+class FbAppPlugin::PageTab < ApplicationRecord
# FIXME: rename table to match model
self.table_name = :fb_app_plugin_page_tab_configs
diff --git a/plugins/foo/lib/foo_plugin/bar.rb b/plugins/foo/lib/foo_plugin/bar.rb
index fe084cf..ebc5cc1 100644
--- a/plugins/foo/lib/foo_plugin/bar.rb
+++ b/plugins/foo/lib/foo_plugin/bar.rb
@@ -1,3 +1,3 @@
-class FooPlugin::Bar < ActiveRecord::Base
+class FooPlugin::Bar < ApplicationRecord
end
diff --git a/plugins/lattes_curriculum/lib/academic_info.rb b/plugins/lattes_curriculum/lib/academic_info.rb
index 27559f8..6ccb586 100644
--- a/plugins/lattes_curriculum/lib/academic_info.rb
+++ b/plugins/lattes_curriculum/lib/academic_info.rb
@@ -1,4 +1,4 @@
-class AcademicInfo < ActiveRecord::Base
+class AcademicInfo < ApplicationRecord
belongs_to :person
diff --git a/plugins/mark_comment_as_read/lib/mark_comment_as_read_plugin/read_comments.rb b/plugins/mark_comment_as_read/lib/mark_comment_as_read_plugin/read_comments.rb
index 51651f1..d6f01b4 100644
--- a/plugins/mark_comment_as_read/lib/mark_comment_as_read_plugin/read_comments.rb
+++ b/plugins/mark_comment_as_read/lib/mark_comment_as_read_plugin/read_comments.rb
@@ -1,4 +1,4 @@
-class MarkCommentAsReadPlugin::ReadComments < ActiveRecord::Base
+class MarkCommentAsReadPlugin::ReadComments < ApplicationRecord
self.table_name = 'mark_comment_as_read_plugin'
belongs_to :comment
belongs_to :person
diff --git a/plugins/newsletter/lib/newsletter_plugin/newsletter.rb b/plugins/newsletter/lib/newsletter_plugin/newsletter.rb
index ef9d0f7..9124c9e 100644
--- a/plugins/newsletter/lib/newsletter_plugin/newsletter.rb
+++ b/plugins/newsletter/lib/newsletter_plugin/newsletter.rb
@@ -1,6 +1,6 @@
require 'csv'
-class NewsletterPlugin::Newsletter < ActiveRecord::Base
+class NewsletterPlugin::Newsletter < ApplicationRecord
belongs_to :environment
belongs_to :person
diff --git a/plugins/oauth_client/models/oauth_client_plugin/auth.rb b/plugins/oauth_client/models/oauth_client_plugin/auth.rb
index a8db3d1..f4b01d8 100644
--- a/plugins/oauth_client/models/oauth_client_plugin/auth.rb
+++ b/plugins/oauth_client/models/oauth_client_plugin/auth.rb
@@ -1,4 +1,4 @@
-class OauthClientPlugin::Auth < ActiveRecord::Base
+class OauthClientPlugin::Auth < ApplicationRecord
belongs_to :profile, class_name: 'Profile'
belongs_to :provider, class_name: 'OauthClientPlugin::Provider'
diff --git a/plugins/oauth_client/models/oauth_client_plugin/provider.rb b/plugins/oauth_client/models/oauth_client_plugin/provider.rb
index 44e6ee7..2846ebd 100644
--- a/plugins/oauth_client/models/oauth_client_plugin/provider.rb
+++ b/plugins/oauth_client/models/oauth_client_plugin/provider.rb
@@ -1,4 +1,4 @@
-class OauthClientPlugin::Provider < ActiveRecord::Base
+class OauthClientPlugin::Provider < ApplicationRecord
belongs_to :environment
diff --git a/plugins/open_graph/models/open_graph_plugin/track.rb b/plugins/open_graph/models/open_graph_plugin/track.rb
index b067f90..198784e 100644
--- a/plugins/open_graph/models/open_graph_plugin/track.rb
+++ b/plugins/open_graph/models/open_graph_plugin/track.rb
@@ -1,4 +1,4 @@
-class OpenGraphPlugin::Track < ActiveRecord::Base
+class OpenGraphPlugin::Track < ApplicationRecord
class_attribute :context
self.context = :open_graph
diff --git a/plugins/orders/models/orders_plugin/item.rb b/plugins/orders/models/orders_plugin/item.rb
index 3130347..c2f7f92 100644
--- a/plugins/orders/models/orders_plugin/item.rb
+++ b/plugins/orders/models/orders_plugin/item.rb
@@ -1,4 +1,4 @@
-class OrdersPlugin::Item < ActiveRecord::Base
+class OrdersPlugin::Item < ApplicationRecord
# flag used by items to compare them with products
attr_accessor :product_diff
diff --git a/plugins/orders/models/orders_plugin/order.rb b/plugins/orders/models/orders_plugin/order.rb
index 55b94d9..83bb818 100644
--- a/plugins/orders/models/orders_plugin/order.rb
+++ b/plugins/orders/models/orders_plugin/order.rb
@@ -1,4 +1,4 @@
-class OrdersPlugin::Order < ActiveRecord::Base
+class OrdersPlugin::Order < ApplicationRecord
# if abstract_class is true then it will trigger https://github.com/rails/rails/issues/20871
#self.abstract_class = true
diff --git a/plugins/orders_cycle/models/orders_cycle_plugin/cycle.rb b/plugins/orders_cycle/models/orders_cycle_plugin/cycle.rb
index ad109b3..582dcd5 100644
--- a/plugins/orders_cycle/models/orders_cycle_plugin/cycle.rb
+++ b/plugins/orders_cycle/models/orders_cycle_plugin/cycle.rb
@@ -1,4 +1,4 @@
-class OrdersCyclePlugin::Cycle < ActiveRecord::Base
+class OrdersCyclePlugin::Cycle < ApplicationRecord
Statuses = %w[edition orders purchases receipts separation delivery closing]
DbStatuses = %w[new] + Statuses
diff --git a/plugins/orders_cycle/models/orders_cycle_plugin/cycle_order.rb b/plugins/orders_cycle/models/orders_cycle_plugin/cycle_order.rb
index 61ccd6e..84b9fa0 100644
--- a/plugins/orders_cycle/models/orders_cycle_plugin/cycle_order.rb
+++ b/plugins/orders_cycle/models/orders_cycle_plugin/cycle_order.rb
@@ -1,4 +1,4 @@
-class OrdersCyclePlugin::CycleOrder < ActiveRecord::Base
+class OrdersCyclePlugin::CycleOrder < ApplicationRecord
belongs_to :cycle, class_name: 'OrdersCyclePlugin::Cycle'
belongs_to :sale, class_name: 'OrdersCyclePlugin::Sale', foreign_key: :sale_id, dependent: :destroy
diff --git a/plugins/orders_cycle/models/orders_cycle_plugin/cycle_product.rb b/plugins/orders_cycle/models/orders_cycle_plugin/cycle_product.rb
index ffaf905..5837fbc 100644
--- a/plugins/orders_cycle/models/orders_cycle_plugin/cycle_product.rb
+++ b/plugins/orders_cycle/models/orders_cycle_plugin/cycle_product.rb
@@ -1,4 +1,4 @@
-class OrdersCyclePlugin::CycleProduct < ActiveRecord::Base
+class OrdersCyclePlugin::CycleProduct < ApplicationRecord
self.table_name = :orders_cycle_plugin_cycle_products
diff --git a/plugins/organization_ratings/lib/organization_rating.rb b/plugins/organization_ratings/lib/organization_rating.rb
index 9d8dd47..9fb484c 100644
--- a/plugins/organization_ratings/lib/organization_rating.rb
+++ b/plugins/organization_ratings/lib/organization_rating.rb
@@ -1,4 +1,4 @@
-class OrganizationRating < ActiveRecord::Base
+class OrganizationRating < ApplicationRecord
belongs_to :person
belongs_to :organization
belongs_to :comment
diff --git a/plugins/organization_ratings/lib/organization_ratings_config.rb b/plugins/organization_ratings/lib/organization_ratings_config.rb
index 383392f..c640a08 100644
--- a/plugins/organization_ratings/lib/organization_ratings_config.rb
+++ b/plugins/organization_ratings/lib/organization_ratings_config.rb
@@ -1,4 +1,4 @@
-class OrganizationRatingsConfig < ActiveRecord::Base
+class OrganizationRatingsConfig < ApplicationRecord
belongs_to :environment
diff --git a/plugins/shopping_cart/db/migrate/20131226125124_move_shopping_cart_purchase_order_to_orders_plugin_order.rb b/plugins/shopping_cart/db/migrate/20131226125124_move_shopping_cart_purchase_order_to_orders_plugin_order.rb
index 9f7749c..2c2d2ed 100644
--- a/plugins/shopping_cart/db/migrate/20131226125124_move_shopping_cart_purchase_order_to_orders_plugin_order.rb
+++ b/plugins/shopping_cart/db/migrate/20131226125124_move_shopping_cart_purchase_order_to_orders_plugin_order.rb
@@ -1,7 +1,7 @@
OrdersPlugin.send :remove_const, :Item if defined? OrdersPlugin::Item
OrdersPlugin.send :remove_const, :Order if defined? OrdersPlugin::Order
-class ShoppingCartPlugin::PurchaseOrder < ActiveRecord::Base
+class ShoppingCartPlugin::PurchaseOrder < ApplicationRecord
acts_as_having_settings field: :data
module Status
@@ -16,10 +16,10 @@ class Profile
has_many :orders, class_name: 'OrdersPlugin::Order'
end
-class OrdersPlugin::Item < ActiveRecord::Base
+class OrdersPlugin::Item < ApplicationRecord
belongs_to :order, class_name: 'OrdersPlugin::Order'
end
-class OrdersPlugin::Order < ActiveRecord::Base
+class OrdersPlugin::Order < ApplicationRecord
has_many :items, class_name: 'OrdersPlugin::Item', foreign_key: :order_id
extend CodeNumbering::ClassMethods
diff --git a/plugins/solr/test/unit/acts_as_faceted_test.rb b/plugins/solr/test/unit/acts_as_faceted_test.rb
index dced575..218544a 100644
--- a/plugins/solr/test/unit/acts_as_faceted_test.rb
+++ b/plugins/solr/test/unit/acts_as_faceted_test.rb
@@ -2,11 +2,11 @@ require_relative '../test_helper'
require "#{File.dirname(__FILE__)}/../../lib/acts_as_faceted"
-class TestModel < ActiveRecord::Base
+class TestModel < ApplicationRecord
def self.f_type_proc(klass)
- klass.constantize
+ klass.constantize
h = {
- 'UploadedFile' => "Uploaded File",
+ 'UploadedFile' => "Uploaded File",
'TextArticle' => "Text",
'Folder' => "Folder",
'Event' => "Event",
@@ -92,7 +92,7 @@ class ActsAsFacetedTest < ActiveSupport::TestCase
assert_equivalent [["[* TO NOW-1YEARS/DAY]", "Older than one year", 10], ["[NOW-1YEARS TO NOW/DAY]", "Last year", 19]], r
end
- should 'return facet hash in map_facets_for' do
+ should 'return facet hash in map_facets_for' do
r = TestModel.map_facets_for(Environment.default)
assert r.count, 2
@@ -147,7 +147,7 @@ class ActsAsFacetedTest < ActiveSupport::TestCase
facets = TestModel.map_facets_for(Environment.default)
facet = facets.select{ |f| f[:id] == 'f_type' }.first
facet_data = TestModel.map_facet_results facet, @facet_params, @facets, @all_facets, {}
- sorted = TestModel.facet_result_sort(facet, facet_data, :alphabetically)
+ sorted = TestModel.facet_result_sort(facet, facet_data, :alphabetically)
assert_equal sorted,
[["Folder", "Folder", 3], ["Gallery", "Gallery", 1], ["TextArticle", 'Text', 15], ["UploadedFile", "Uploaded File", 6]]
end
@@ -156,7 +156,7 @@ class ActsAsFacetedTest < ActiveSupport::TestCase
facets = TestModel.map_facets_for(Environment.default)
facet = facets.select{ |f| f[:id] == 'f_type' }.first
facet_data = TestModel.map_facet_results facet, @facet_params, @facets, @all_facets, {}
- sorted = TestModel.facet_result_sort(facet, facet_data, :count)
+ sorted = TestModel.facet_result_sort(facet, facet_data, :count)
assert_equal sorted,
[["TextArticle", "Text", 15], ["UploadedFile", "Uploaded File", 6], ["Folder", "Folder", 3], ["Gallery", "Gallery", 1]]
end
diff --git a/plugins/solr/vendor/plugins/acts_as_solr_reloaded/lib/acts_as_solr/dynamic_attribute.rb b/plugins/solr/vendor/plugins/acts_as_solr_reloaded/lib/acts_as_solr/dynamic_attribute.rb
index 29f8d2c..73b5f04 100644
--- a/plugins/solr/vendor/plugins/acts_as_solr_reloaded/lib/acts_as_solr/dynamic_attribute.rb
+++ b/plugins/solr/vendor/plugins/acts_as_solr_reloaded/lib/acts_as_solr/dynamic_attribute.rb
@@ -1,3 +1,3 @@
-class DynamicAttribute < ActiveRecord::Base
+class DynamicAttribute < ApplicationRecord
belongs_to :dynamicable, :polymorphic => true
end
diff --git a/plugins/spaminator/lib/spaminator_plugin/report.rb b/plugins/spaminator/lib/spaminator_plugin/report.rb
index d61c8dd..6599051 100644
--- a/plugins/spaminator/lib/spaminator_plugin/report.rb
+++ b/plugins/spaminator/lib/spaminator_plugin/report.rb
@@ -1,4 +1,4 @@
-class SpaminatorPlugin::Report < ActiveRecord::Base
+class SpaminatorPlugin::Report < ApplicationRecord
serialize :failed, Hash
diff --git a/plugins/stoa/lib/stoa_plugin/usp_aluno_turma_grad.rb b/plugins/stoa/lib/stoa_plugin/usp_aluno_turma_grad.rb
index a5c362f..a634d07 100644
--- a/plugins/stoa/lib/stoa_plugin/usp_aluno_turma_grad.rb
+++ b/plugins/stoa/lib/stoa_plugin/usp_aluno_turma_grad.rb
@@ -1,4 +1,4 @@
-class StoaPlugin::UspAlunoTurmaGrad < ActiveRecord::Base
+class StoaPlugin::UspAlunoTurmaGrad < ApplicationRecord
establish_connection(:stoa)
diff --git a/plugins/stoa/lib/stoa_plugin/usp_user.rb b/plugins/stoa/lib/stoa_plugin/usp_user.rb
index e841a14..50c2d0f 100644
--- a/plugins/stoa/lib/stoa_plugin/usp_user.rb
+++ b/plugins/stoa/lib/stoa_plugin/usp_user.rb
@@ -1,4 +1,4 @@
-class StoaPlugin::UspUser < ActiveRecord::Base
+class StoaPlugin::UspUser < ApplicationRecord
establish_connection(:stoa)
self.table_name = 'pessoa'
diff --git a/plugins/sub_organizations/lib/sub_organizations_plugin/approve_paternity_relation.rb b/plugins/sub_organizations/lib/sub_organizations_plugin/approve_paternity_relation.rb
index 4741b75..f29fb16 100644
--- a/plugins/sub_organizations/lib/sub_organizations_plugin/approve_paternity_relation.rb
+++ b/plugins/sub_organizations/lib/sub_organizations_plugin/approve_paternity_relation.rb
@@ -1,4 +1,4 @@
-class SubOrganizationsPlugin::ApprovePaternityRelation < ActiveRecord::Base
+class SubOrganizationsPlugin::ApprovePaternityRelation < ApplicationRecord
belongs_to :task
belongs_to :parent, :polymorphic => true
diff --git a/plugins/sub_organizations/lib/sub_organizations_plugin/relation.rb b/plugins/sub_organizations/lib/sub_organizations_plugin/relation.rb
index 03e9010..e149ad6 100644
--- a/plugins/sub_organizations/lib/sub_organizations_plugin/relation.rb
+++ b/plugins/sub_organizations/lib/sub_organizations_plugin/relation.rb
@@ -1,4 +1,4 @@
-class SubOrganizationsPlugin::Relation < ActiveRecord::Base
+class SubOrganizationsPlugin::Relation < ApplicationRecord
belongs_to :parent, :polymorphic => true
belongs_to :child, :polymorphic => true
diff --git a/plugins/suppliers/db/migrate/20130902115916_add_active_to_suppliers_plugin_supplier.rb b/plugins/suppliers/db/migrate/20130902115916_add_active_to_suppliers_plugin_supplier.rb
index 2b9baf4..fefd2f8 100644
--- a/plugins/suppliers/db/migrate/20130902115916_add_active_to_suppliers_plugin_supplier.rb
+++ b/plugins/suppliers/db/migrate/20130902115916_add_active_to_suppliers_plugin_supplier.rb
@@ -1,4 +1,4 @@
-class SuppliersPlugin::Supplier < ActiveRecord::Base
+class SuppliersPlugin::Supplier < ApplicationRecord
end
class AddActiveToSuppliersPluginSupplier < ActiveRecord::Migration
diff --git a/plugins/suppliers/models/suppliers_plugin/source_product.rb b/plugins/suppliers/models/suppliers_plugin/source_product.rb
index 8f256e2..c157323 100644
--- a/plugins/suppliers/models/suppliers_plugin/source_product.rb
+++ b/plugins/suppliers/models/suppliers_plugin/source_product.rb
@@ -1,4 +1,4 @@
-class SuppliersPlugin::SourceProduct < ActiveRecord::Base
+class SuppliersPlugin::SourceProduct < ApplicationRecord
default_scope -> { includes :from_product, :to_product }
diff --git a/plugins/suppliers/models/suppliers_plugin/supplier.rb b/plugins/suppliers/models/suppliers_plugin/supplier.rb
index 93b11d0..eef95de 100644
--- a/plugins/suppliers/models/suppliers_plugin/supplier.rb
+++ b/plugins/suppliers/models/suppliers_plugin/supplier.rb
@@ -1,4 +1,4 @@
-class SuppliersPlugin::Supplier < ActiveRecord::Base
+class SuppliersPlugin::Supplier < ApplicationRecord
attr_accessor :distribute_products_on_create, :dont_destroy_dummy, :identifier_from_name
diff --git a/plugins/tolerance_time/lib/tolerance_time_plugin/publication.rb b/plugins/tolerance_time/lib/tolerance_time_plugin/publication.rb
index 068d1bd..40abbf4 100644
--- a/plugins/tolerance_time/lib/tolerance_time_plugin/publication.rb
+++ b/plugins/tolerance_time/lib/tolerance_time_plugin/publication.rb
@@ -1,4 +1,4 @@
-class ToleranceTimePlugin::Publication < ActiveRecord::Base
+class ToleranceTimePlugin::Publication < ApplicationRecord
belongs_to :target, :polymorphic => true
diff --git a/plugins/tolerance_time/lib/tolerance_time_plugin/tolerance.rb b/plugins/tolerance_time/lib/tolerance_time_plugin/tolerance.rb
index b0e1d91..b8f5948 100644
--- a/plugins/tolerance_time/lib/tolerance_time_plugin/tolerance.rb
+++ b/plugins/tolerance_time/lib/tolerance_time_plugin/tolerance.rb
@@ -1,4 +1,4 @@
-class ToleranceTimePlugin::Tolerance < ActiveRecord::Base
+class ToleranceTimePlugin::Tolerance < ApplicationRecord
belongs_to :profile
diff --git a/plugins/volunteers/models/volunteers_plugin/assignment.rb b/plugins/volunteers/models/volunteers_plugin/assignment.rb
index e7cbcc4..be1a96f 100644
--- a/plugins/volunteers/models/volunteers_plugin/assignment.rb
+++ b/plugins/volunteers/models/volunteers_plugin/assignment.rb
@@ -1,4 +1,4 @@
-class VolunteersPlugin::Assignment < ActiveRecord::Base
+class VolunteersPlugin::Assignment < ApplicationRecord
belongs_to :profile
belongs_to :period, class_name: 'VolunteersPlugin::Period'
diff --git a/plugins/volunteers/models/volunteers_plugin/period.rb b/plugins/volunteers/models/volunteers_plugin/period.rb
index c44c505..31a2e19 100644
--- a/plugins/volunteers/models/volunteers_plugin/period.rb
+++ b/plugins/volunteers/models/volunteers_plugin/period.rb
@@ -1,4 +1,4 @@
-class VolunteersPlugin::Period < ActiveRecord::Base
+class VolunteersPlugin::Period < ApplicationRecord
belongs_to :owner, polymorphic: true
diff --git a/test/mocks/test/environment.rb b/test/mocks/test/environment.rb
index 8277ae9..8bf5dc5 100644
--- a/test/mocks/test/environment.rb
+++ b/test/mocks/test/environment.rb
@@ -1,6 +1,6 @@
require File.expand_path(File.dirname(__FILE__) + "/../../../app/models/environment")
-class Environment < ActiveRecord::Base
+class Environment < ApplicationRecord
def self.available_features
{
'feature1' => 'Enable Feature 1',
diff --git a/test/support/factories.rb b/test/support/factories.rb
index ccbac85..d39e560 100644
--- a/test/support/factories.rb
+++ b/test/support/factories.rb
@@ -5,9 +5,9 @@ module Noosfero::Factory
attrs[:slug] = attrs[:name].to_slug if attrs[:name].present? && attrs[:slug].blank? && defaults[:slug].present?
data = defaults_for(name.to_s.gsub('::','')).merge(attrs)
klass = name.to_s.camelize.constantize
- if klass.superclass != ActiveRecord::Base
- data[:type] = klass.to_s
- end
+
+ data[:type] = klass.to_s if klass.column_names.include? 'type'
+
if options[:timestamps]
fast_insert_with_timestamps(klass, data)
else
--
libgit2 0.21.2