Commit 1676500ee81f8b768de2e9fa766ce7a00d089369

Authored by Braulio Bhavamitra
1 parent a7561344

Use ApplicationRecord pattern

Anticipating a pattern from Rails 5
Showing 167 changed files with 310 additions and 353 deletions   Show diff stats

Too many changes.

To preserve performance only 100 of 167 files displayed.

README.rails.md
... ... @@ -99,7 +99,7 @@ Description of contents
99 99 Holds controllers that should be named like weblog_controller.rb for automated URL mapping. All controllers should descend from `ActionController::Base`.
100 100  
101 101 * `app/models`
102   - Holds models that should be named like post.rb. Most models will descend from `ActiveRecord::Base`.
  102 + Holds models that should be named like post.rb. Most models will descend from `ApplicationRecord`.
103 103  
104 104 * `app/views`
105 105 Holds the template files for the view that should be named like `weblog/index.rhtml` for the `WeblogController#index` action. All views use eRuby syntax. This directory can also be used to keep stylesheets, images, and so on that can be symlinked to public.
... ...
app/mailers/mailing.rb
1 1 require_dependency 'mailing_job'
2 2  
3   -class Mailing < ActiveRecord::Base
  3 +class Mailing < ApplicationRecord
4 4  
5 5 acts_as_having_settings :field => :data
6 6  
... ...
app/models/abuse_report.rb
1   -class AbuseReport < ActiveRecord::Base
  1 +class AbuseReport < ApplicationRecord
2 2  
3 3 attr_accessible :content, :reason
4 4  
... ...
app/models/action_tracker_notification.rb
1   -class ActionTrackerNotification < ActiveRecord::Base
  1 +class ActionTrackerNotification < ApplicationRecord
2 2  
3 3 belongs_to :profile
4 4 belongs_to :action_tracker, :class_name => 'ActionTracker::Record', :foreign_key => 'action_tracker_id'
... ...
app/models/application_record.rb 0 → 100644
... ... @@ -0,0 +1,64 @@
  1 +class ApplicationRecord < ActiveRecord::Base
  2 +
  3 + self.abstract_class = true
  4 +
  5 + def self.postgresql?
  6 + self.connection.adapter_name == 'PostgreSQL'
  7 + end
  8 +
  9 + # an ActionView instance for rendering views on models
  10 + def self.action_view
  11 + @action_view ||= begin
  12 + view_paths = ::ActionController::Base.view_paths
  13 + action_view = ::ActionView::Base.new view_paths
  14 + # for using Noosfero helpers inside render calls
  15 + action_view.extend ::ApplicationHelper
  16 + action_view
  17 + end
  18 + end
  19 +
  20 + # default value needed for the above ActionView
  21 + def to_partial_path
  22 + self.class.name.underscore
  23 + end
  24 +
  25 + alias :meta_cache_key :cache_key
  26 + def cache_key
  27 + key = [Noosfero::VERSION, meta_cache_key]
  28 + key.unshift(ApplicationRecord.connection.schema_search_path) if ApplicationRecord.postgresql?
  29 + key.join('/')
  30 + end
  31 +
  32 + def self.like_search(query, options={})
  33 + if defined?(self::SEARCHABLE_FIELDS) || options[:fields].present?
  34 + fields_per_table = {}
  35 + fields_per_table[table_name] = (options[:fields].present? ? options[:fields] : self::SEARCHABLE_FIELDS.keys.map(&:to_s)) & column_names
  36 +
  37 + if options[:joins].present?
  38 + join_asset = options[:joins].to_s.classify.constantize
  39 + if defined?(join_asset::SEARCHABLE_FIELDS) || options[:fields].present?
  40 + fields_per_table[join_asset.table_name] = (options[:fields].present? ? options[:fields] : join_asset::SEARCHABLE_FIELDS.keys.map(&:to_s)) & join_asset.column_names
  41 + end
  42 + end
  43 +
  44 + query = query.downcase.strip
  45 + fields_per_table.delete_if { |table,fields| fields.blank? }
  46 + conditions = fields_per_table.map do |table,fields|
  47 + fields.map do |field|
  48 + "lower(#{table}.#{field}) LIKE '%#{query}%'"
  49 + end.join(' OR ')
  50 + end.join(' OR ')
  51 +
  52 + if options[:joins].present?
  53 + joins(options[:joins]).where(conditions)
  54 + else
  55 + where(conditions)
  56 + end
  57 +
  58 + else
  59 + raise "No searchable fields defined for #{self.name}"
  60 + end
  61 + end
  62 +
  63 +end
  64 +
... ...
app/models/article.rb
1 1  
2   -class Article < ActiveRecord::Base
  2 +class Article < ApplicationRecord
3 3  
4 4 include SanitizeHelper
5 5  
... ...
app/models/article_categorization.rb
1   -class ArticleCategorization < ActiveRecord::Base
  1 +class ArticleCategorization < ApplicationRecord
2 2 self.table_name = :articles_categories
3 3  
4 4 belongs_to :article
... ...
app/models/article_follower.rb
1   -class ArticleFollower < ActiveRecord::Base
  1 +class ArticleFollower < ApplicationRecord
2 2  
3 3 attr_accessible :article_id, :person_id
4 4 belongs_to :article, :counter_cache => :followers_count
... ...
app/models/block.rb
1   -class Block < ActiveRecord::Base
  1 +class Block < ApplicationRecord
2 2  
3 3 attr_accessible :title, :subtitle, :display, :limit, :box_id, :posts_per_page,
4 4 :visualization_format, :language, :display_user,
... ...
app/models/box.rb
1   -class Box < ActiveRecord::Base
  1 +class Box < ApplicationRecord
2 2  
3 3 acts_as_list scope: -> box { where owner_id: box.owner_id, owner_type: box.owner_type }
4 4  
... ...
app/models/category.rb
1   -class Category < ActiveRecord::Base
  1 +class Category < ApplicationRecord
2 2  
3 3 attr_accessible :name, :parent_id, :display_color, :display_in_menu, :image_builder, :environment, :parent
4 4  
... ...
app/models/certifier.rb
1   -class Certifier < ActiveRecord::Base
  1 +class Certifier < ApplicationRecord
2 2  
3 3 attr_accessible :name, :environment
4 4  
... ...
app/models/chat_message.rb
1   -class ChatMessage < ActiveRecord::Base
  1 +class ChatMessage < ApplicationRecord
  2 +
2 3 attr_accessible :body, :from, :to
3 4  
4 5 belongs_to :to, :class_name => 'Profile'
... ...
app/models/comment.rb
1   -class Comment < ActiveRecord::Base
  1 +class Comment < ApplicationRecord
2 2  
3 3 SEARCHABLE_FIELDS = {
4 4 :title => {:label => _('Title'), :weight => 10},
... ...
app/models/contact_list.rb
1   -class ContactList < ActiveRecord::Base
  1 +class ContactList < ApplicationRecord
2 2  
3 3 serialize :list, Array
4 4  
... ...
app/models/custom_field.rb
1   -class CustomField < ActiveRecord::Base
  1 +class CustomField < ApplicationRecord
  2 +
2 3 attr_accessible :name, :default_value, :format, :extras, :customized_type, :active, :required, :signup, :environment, :moderation_task
3 4 serialize :customized_type
4 5 serialize :extras
... ...
app/models/custom_field_value.rb
1   -class CustomFieldValue < ActiveRecord::Base
  1 +class CustomFieldValue < ApplicationRecord
  2 +
2 3 belongs_to :custom_field
3 4 belongs_to :customized, :polymorphic => true
4 5 attr_accessible :value, :public, :customized, :custom_field, :customized_type
... ...
app/models/domain.rb
1 1 require 'noosfero/multi_tenancy'
2 2  
3   -class Domain < ActiveRecord::Base
  3 +class Domain < ApplicationRecord
4 4  
5 5 attr_accessible :name, :owner, :is_default
6 6  
... ...
app/models/email_template.rb
1   -class EmailTemplate < ActiveRecord::Base
  1 +class EmailTemplate < ApplicationRecord
2 2  
3 3 belongs_to :owner, :polymorphic => true
4 4  
... ...
app/models/environment.rb
1 1 # A Environment is like a website to be hosted in the platform. It may
2 2 # contain multiple Profile's and can be identified by several different
3 3 # domains.
4   -class Environment < ActiveRecord::Base
  4 +class Environment < ApplicationRecord
5 5  
6 6 attr_accessible :name, :is_default, :signup_welcome_text_subject,
7 7 :signup_welcome_text_body, :terms_of_use,
... ...
app/models/external_feed.rb
1   -class ExternalFeed < ActiveRecord::Base
  1 +class ExternalFeed < ApplicationRecord
2 2  
3 3 belongs_to :blog
4 4 validates_presence_of :blog_id
... ...
app/models/favorite_enterprise_person.rb
1   -class FavoriteEnterprisePerson < ActiveRecord::Base
  1 +class FavoriteEnterprisePerson < ApplicationRecord
2 2  
3 3 attr_accessible :person, :enterprise
4 4  
... ...
app/models/friendship.rb
1   -class Friendship < ActiveRecord::Base
  1 +class Friendship < ApplicationRecord
2 2 track_actions :new_friendship, :after_create, :keep_params => ["friend.name", "friend.url", "friend.profile_custom_icon"], :custom_user => :person
3 3  
4 4 extend CacheCounterHelper
... ...
app/models/image.rb
1   -class Image < ActiveRecord::Base
  1 +class Image < ApplicationRecord
2 2  
3 3 attr_accessible :uploaded_data, :label, :remove_image
4 4 attr_accessor :remove_image
... ...
app/models/input.rb
1   -class Input < ActiveRecord::Base
  1 +class Input < ApplicationRecord
2 2  
3 3 attr_accessible :product, :product_id, :product_category, :product_category_id,
4 4 :amount_used, :unit_id, :price_per_unit, :relevant_to_price, :is_from_solidarity_economy
... ...
app/models/license.rb
1   -class License < ActiveRecord::Base
  1 +class License < ApplicationRecord
2 2  
3 3 attr_accessible :name, :url
4 4  
... ...
app/models/mailing_sent.rb
1   -class MailingSent < ActiveRecord::Base
  1 +class MailingSent < ApplicationRecord
  2 +
2 3 attr_accessible :person
3 4 belongs_to :mailing
4 5 belongs_to :person
... ...
app/models/national_region.rb
1   -class NationalRegion < ActiveRecord::Base
  1 +class NationalRegion < ApplicationRecord
2 2  
3 3 SEARCHABLE_FIELDS = {
4 4 :name => {:label => _('Name'), :weight => 1},
... ...
app/models/national_region_type.rb
1   -class NationalRegionType < ActiveRecord::Base
  1 +class NationalRegionType < ApplicationRecord
2 2 COUNTRY = 1
3 3 STATE = 2
4 4 CITY = 3
... ...
app/models/person.rb
... ... @@ -336,7 +336,7 @@ class Person &lt; Profile
336 336 environment ||= self.environment
337 337 role_assignments.includes([:role, :resource]).select { |ra| ra.resource == environment }.map{|ra|ra.role.permissions}.any? do |ps|
338 338 ps.any? do |p|
339   - ActiveRecord::Base::PERMISSIONS['Environment'].keys.include?(p)
  339 + ApplicationRecord::PERMISSIONS['Environment'].keys.include?(p)
340 340 end
341 341 end
342 342 end
... ...
app/models/price_detail.rb
1   -class PriceDetail < ActiveRecord::Base
  1 +class PriceDetail < ApplicationRecord
2 2  
3 3 attr_accessible :price, :production_cost_id
4 4  
... ...
app/models/product.rb
1   -class Product < ActiveRecord::Base
  1 +class Product < ApplicationRecord
2 2  
3 3 SEARCHABLE_FIELDS = {
4 4 :name => {:label => _('Name'), :weight => 10},
... ...
app/models/product_qualifier.rb
1   -class ProductQualifier < ActiveRecord::Base
  1 +class ProductQualifier < ApplicationRecord
2 2  
3 3 attr_accessible :qualifier, :product, :certifier
4 4  
... ...
app/models/production_cost.rb
1   -class ProductionCost < ActiveRecord::Base
  1 +class ProductionCost < ApplicationRecord
2 2  
3 3 attr_accessible :name, :owner
4 4  
... ...
app/models/profile.rb
1 1 # A Profile is the representation and web-presence of an individual or an
2 2 # organization. Every Profile is attached to its Environment of origin,
3 3 # which by default is the one returned by Environment:default.
4   -class Profile < ActiveRecord::Base
  4 +class Profile < ApplicationRecord
5 5  
6 6 attr_accessible :name, :identifier, :public_profile, :nickname, :custom_footer, :custom_header, :address, :zip_code, :contact_phone, :image_builder, :description, :closed, :template_id, :environment, :lat, :lng, :is_template, :fields_privacy, :preferred_domain_id, :category_ids, :country, :city, :state, :national_region_code, :email, :contact_email, :redirect_l10n, :notification_time,
7 7 :redirection_after_login, :custom_url_redirection,
... ...
app/models/profile_activity.rb
1   -class ProfileActivity < ActiveRecord::Base
  1 +class ProfileActivity < ApplicationRecord
2 2  
3 3 self.record_timestamps = false
4 4  
... ...
app/models/profile_categorization.rb
1   -class ProfileCategorization < ActiveRecord::Base
  1 +class ProfileCategorization < ApplicationRecord
2 2 self.table_name = :categories_profiles
3 3 belongs_to :profile
4 4 belongs_to :category
... ...
app/models/profile_suggestion.rb
1   -class ProfileSuggestion < ActiveRecord::Base
  1 +class ProfileSuggestion < ApplicationRecord
  2 +
2 3 belongs_to :person
3 4 belongs_to :suggestion, :class_name => 'Profile', :foreign_key => :suggestion_id
4 5  
... ...
app/models/qualifier.rb
1   -class Qualifier < ActiveRecord::Base
  1 +class Qualifier < ApplicationRecord
2 2  
3 3 attr_accessible :name, :environment
4 4  
... ...
app/models/qualifier_certifier.rb
1   -class QualifierCertifier < ActiveRecord::Base
  1 +class QualifierCertifier < ApplicationRecord
2 2 belongs_to :qualifier
3 3 belongs_to :certifier
4 4  
... ...
app/models/reported_image.rb
1   -class ReportedImage < ActiveRecord::Base
  1 +class ReportedImage < ApplicationRecord
2 2 belongs_to :abuse_report
3 3  
4 4 validates_presence_of :abuse_report
... ...
app/models/scrap.rb
1   -class Scrap < ActiveRecord::Base
  1 +class Scrap < ApplicationRecord
2 2  
3 3 include SanitizeHelper
4 4  
... ...
app/models/search_term.rb
1   -class SearchTerm < ActiveRecord::Base
  1 +class SearchTerm < ApplicationRecord
2 2 validates_presence_of :term, :context
3 3 validates_uniqueness_of :term, :scope => [:context_id, :context_type, :asset]
4 4  
... ... @@ -25,7 +25,7 @@ class SearchTerm &lt; ActiveRecord::Base
25 25 # Therefore the score is 97. Them we sum every score to get the total score
26 26 # for a search term.
27 27 def self.occurrences_scores
28   - Hash[*ActiveRecord::Base.connection.execute(
  28 + Hash[*ApplicationRecord.connection.execute(
29 29 joins(:occurrences).
30 30 select("search_terms.id, sum(#{SearchTermOccurrence::EXPIRATION_TIME.to_i} - extract(epoch from (now() - search_term_occurrences.created_at))) as value").
31 31 where("search_term_occurrences.created_at > ?", DateTime.now - SearchTermOccurrence::EXPIRATION_TIME).
... ...
app/models/search_term_occurrence.rb
1   -class SearchTermOccurrence < ActiveRecord::Base
  1 +class SearchTermOccurrence < ApplicationRecord
2 2  
3 3 belongs_to :search_term
4 4 validates_presence_of :search_term
... ...
app/models/suggestion_connection.rb
1   -class SuggestionConnection < ActiveRecord::Base
  1 +class SuggestionConnection < ApplicationRecord
  2 +
2 3 attr_accessible :suggestion, :suggestion_id, :connection_type, :connection_id
3 4  
4 5 belongs_to :suggestion, :class_name => 'ProfileSuggestion', :foreign_key => 'suggestion_id'
... ...
app/models/task.rb
... ... @@ -9,7 +9,7 @@
9 9 # This class has a +data+ field of type <tt>text</tt>, where you can store any
10 10 # type of data (as serialized Ruby objects) you need for your subclass (which
11 11 # will need to declare <ttserialize</tt> itself).
12   -class Task < ActiveRecord::Base
  12 +class Task < ApplicationRecord
13 13  
14 14 acts_as_having_settings :field => :data
15 15  
... ...
app/models/thumbnail.rb
1   -class Thumbnail < ActiveRecord::Base
  1 +class Thumbnail < ApplicationRecord
2 2  
3 3 attr_accessible :uploaded_data
4 4 # mass assigned by attachment_fu
... ...
app/models/unit.rb
1   -class Unit < ActiveRecord::Base
  1 +class Unit < ApplicationRecord
2 2  
3 3 acts_as_list scope: -> unit { where environment_id: unit.environment_id }
4 4  
... ...
app/models/user.rb
... ... @@ -4,7 +4,7 @@ require &#39;securerandom&#39;
4 4  
5 5 # User models the system users, and is generated by the acts_as_authenticated
6 6 # Rails generator.
7   -class User < ActiveRecord::Base
  7 +class User < ApplicationRecord
8 8  
9 9 attr_accessible :login, :email, :password, :password_confirmation, :activated_at
10 10  
... ...
app/models/validation_info.rb
1   -class ValidationInfo < ActiveRecord::Base
  1 +class ValidationInfo < ApplicationRecord
2 2  
3 3 attr_accessible :validation_methodology, :restrictions, :organization
4 4  
... ...
app/views/profile_roles/_form.html.erb
... ... @@ -9,7 +9,7 @@
9 9 <% permissions.each do |key| %>
10 10 <div class="permissions <%= key.downcase %>">
11 11 <h4><%= _('%s Permissions:' % key) %></h4>
12   - <% ActiveRecord::Base::PERMISSIONS[key].keys.each do |p| %>
  12 + <% ApplicationRecord::PERMISSIONS[key].keys.each do |p| %>
13 13 <%= check_box_tag("role[permissions][]", p, role.has_permission?(p), { :id => p }) %>
14 14 <%= content_tag(:label, permission_name(p), { :for => p }) %><br/>
15 15 <% end %>
... ...
app/views/role/_form.html.erb
... ... @@ -9,7 +9,7 @@
9 9 <% permissions.each do |key| %>
10 10 <div class="permissions <%= key.downcase %>">
11 11 <h4><%= _('%s Permissions:' % key) %></h4>
12   - <% ActiveRecord::Base::PERMISSIONS[key].keys.each do |p| %>
  12 + <% ApplicationRecord::PERMISSIONS[key].keys.each do |p| %>
13 13 <%= check_box_tag("role[permissions][]", p, role.has_permission?(p), { :id => p }) %>
14 14 <%= content_tag(:label, permission_name(p), { :for => p }) %><br/>
15 15 <% end %>
... ...
config/initializers/active_record_extensions.rb
... ... @@ -14,4 +14,5 @@ module ActiveRecordExtension
14 14 end
15 15 end
16 16 end
17   -ActiveRecord::Base.send(:include, ActiveRecordExtension)
  17 +
  18 +ApplicationRecord.send :include, ActiveRecordExtension
... ...
db/migrate/033_destroy_organization_and_person_infos.rb
1 1 class DestroyOrganizationAndPersonInfos < ActiveRecord::Migration
2 2 def self.up
3 3 Person.find_each do |i|
4   - info = ActiveRecord::Base.connection.select_one("select * from person_infos where person_id = #{i.id}")
  4 + info = ApplicationRecord.connection.select_one("select * from person_infos where person_id = #{i.id}")
5 5 i.name = info["name"] unless info["name"].nil?
6 6 i.address = info["address"] unless info["address"].nil?
7 7 [ "photo", "contact_information", "birth_date", "sex", "city", "state", "country" ].each do |field|
... ... @@ -12,7 +12,7 @@ class DestroyOrganizationAndPersonInfos &lt; ActiveRecord::Migration
12 12 drop_table :person_infos
13 13  
14 14 Organization.find_each do |i|
15   - info = ActiveRecord::Base.connection.select_one("select * from organization_infos where organization_id = #{i.id}")
  15 + info = ApplicationRecord.connection.select_one("select * from organization_infos where organization_id = #{i.id}")
16 16 [ "contact_person", "contact_email", "acronym", "foundation_year", "legal_form", "economic_activity", "management_information", "validated" ].each do |field|
17 17 i.send("#{field}=", info[field])
18 18 end
... ...
db/migrate/059_add_birth_date_to_person.rb
... ... @@ -29,7 +29,7 @@ class AddBirthDateToPerson &lt; ActiveRecord::Migration
29 29 end
30 30 end
31 31  
32   - class Person < ActiveRecord::Base
  32 + class Person < ApplicationRecord
33 33 self.table_name = 'profiles'
34 34 serialize :data, Hash
35 35 end
... ...
db/migrate/069_add_enviroment_id_to_role.rb
1   -class Role < ActiveRecord::Base; end
2   -class RoleWithEnvironment < ActiveRecord::Base
  1 +class Role < ApplicationRecord
  2 +class RoleWithEnvironment < ApplicationRecord
3 3 self.table_name = 'roles'
4 4 belongs_to :environment
5 5 end
6   -class RoleAssignment < ActiveRecord::Base
  6 +class RoleAssignment < ApplicationRecord
7 7 belongs_to :accessor, :polymorphic => true
8 8 belongs_to :resource, :polymorphic => true
9 9 end
... ...
db/migrate/074_move_title_to_name_from_blogs.rb
... ... @@ -2,7 +2,7 @@ class MoveTitleToNameFromBlogs &lt; ActiveRecord::Migration
2 2 def self.up
3 3 select_all("select id, setting from articles where type = 'Blog' and name != 'Blog'").each do |blog|
4 4 title = YAML.load(blog['setting'])[:title]
5   - assignments = ActiveRecord::Base.sanitize_sql_for_assignment(:name => title)
  5 + assignments = ApplicationRecord.sanitize_sql_for_assignment(:name => title)
6 6 update("update articles set %s where id = %d" % [assignments, blog['id']] )
7 7 end
8 8 end
... ...
db/migrate/20100921121528_add_is_image_to_articles.rb
... ... @@ -3,7 +3,7 @@ class AddIsImageToArticles &lt; ActiveRecord::Migration
3 3 add_column :articles, :is_image, :boolean, :default => false
4 4 add_column :article_versions, :is_image, :boolean, :default => false
5 5  
6   - execute ActiveRecord::Base.sanitize_sql(["update articles set is_image = ? where articles.content_type like 'image/%'", true])
  6 + execute ApplicationRecord.sanitize_sql(["update articles set is_image = ? where articles.content_type like 'image/%'", true])
7 7 end
8 8  
9 9 def self.down
... ...
db/migrate/20101129234429_convert_folders_to_galleries.rb
... ... @@ -10,7 +10,7 @@ class ConvertFoldersToGalleries &lt; ActiveRecord::Migration
10 10 select_all("select id, setting from articles where type = 'Gallery'").each do |folder|
11 11 settings = YAML.load(folder['setting'] || {}.to_yaml)
12 12 settings[:view_as] = 'image_gallery'
13   - assignments = ActiveRecord::Base.sanitize_sql_for_assignment(:setting => settings.to_yaml)
  13 + assignments = ApplicationRecord.sanitize_sql_for_assignment(:setting => settings.to_yaml)
14 14 update("update articles set %s, type = 'Folder' where id = %d" % [assignments, folder['id']])
15 15 end
16 16 end
... ...
db/migrate/20101202205446_remove_published_articles.rb
... ... @@ -3,7 +3,7 @@ class RemovePublishedArticles &lt; ActiveRecord::Migration
3 3 select_all("SELECT * from articles WHERE type = 'PublishedArticle'").each do |published|
4 4 reference = select_one('select * from articles where id = %d' % published['reference_article_id'])
5 5 if reference
6   - execute(ActiveRecord::Base.sanitize_sql(["UPDATE articles SET type = ?, abstract = ?, body = ? WHERE articles.id = ?", reference['type'], reference['abstract'], reference['body'], published['id']]))
  6 + execute(ApplicationRecord.sanitize_sql(["UPDATE articles SET type = ?, abstract = ?, body = ? WHERE articles.id = ?", reference['type'], reference['abstract'], reference['body'], published['id']]))
7 7 else
8 8 execute("DELETE from articles where articles.id = #{published['id']}")
9 9 end
... ...
db/migrate/20101205034144_add_language_and_translation_of_id_to_article.rb
... ... @@ -11,7 +11,7 @@ class AddLanguageAndTranslationOfIdToArticle &lt; ActiveRecord::Migration
11 11 select_all("select id, setting from articles where type = 'Blog'").each do |blog|
12 12 settings = YAML.load(blog['setting'] || {}.to_yaml)
13 13 settings[:display_posts_in_current_language] = true
14   - assignments = ActiveRecord::Base.sanitize_sql_for_assignment(:setting => settings.to_yaml)
  14 + assignments = ApplicationRecord.sanitize_sql_for_assignment(:setting => settings.to_yaml)
15 15 update("update articles set %s where id = %d" % [assignments, blog['id']])
16 16 end
17 17  
... ...
db/migrate/20110203160153_rename_images_path_on_tracked_actions.rb
... ... @@ -15,7 +15,7 @@ class RenameImagesPathOnTrackedActions &lt; ActiveRecord::Migration
15 15 end
16 16 params[param_name] = paths
17 17  
18   - execute(ActiveRecord::Base.sanitize_sql(["UPDATE action_tracker SET params = ? WHERE id = ?", params.to_yaml, tracker['id']]))
  18 + execute(ApplicationRecord.sanitize_sql(["UPDATE action_tracker SET params = ? WHERE id = ?", params.to_yaml, tracker['id']]))
19 19 end
20 20 end
21 21  
... ...
db/migrate/20110215153624_move_data_serialized_hash_to_setting_field_for_articles.rb
... ... @@ -12,9 +12,9 @@ class MoveDataSerializedHashToSettingFieldForArticles &lt; ActiveRecord::Migration
12 12 end
13 13 if body.kind_of?(Hash)
14 14 settings = article.setting.merge(body)
15   - body = ActiveRecord::Base.sanitize_sql_for_assignment(:body => settings[:description])
  15 + body = ApplicationRecord.sanitize_sql_for_assignment(:body => settings[:description])
16 16 update("UPDATE articles set %s WHERE id = %d" % [body, article.id])
17   - setting = ActiveRecord::Base.sanitize_sql_for_assignment(:setting => settings.to_yaml)
  17 + setting = ApplicationRecord.sanitize_sql_for_assignment(:setting => settings.to_yaml)
18 18 update("UPDATE articles set %s WHERE id = %d" % [setting, article.id])
19 19 end
20 20 end
... ...
db/migrate/20110302214607_move_data_serialized_hash_to_setting_field_for_events.rb
... ... @@ -11,9 +11,9 @@ class MoveDataSerializedHashToSettingFieldForEvents &lt; ActiveRecord::Migration
11 11 end
12 12 if body.kind_of?(Hash)
13 13 settings = article.setting.merge(body)
14   - body = ActiveRecord::Base.sanitize_sql_for_assignment(:body => settings[:description])
  14 + body = ApplicationRecord.sanitize_sql_for_assignment(:body => settings[:description])
15 15 update("UPDATE articles set %s WHERE id = %d" % [body, article.id])
16   - setting = ActiveRecord::Base.sanitize_sql_for_assignment(:setting => settings.to_yaml)
  16 + setting = ApplicationRecord.sanitize_sql_for_assignment(:setting => settings.to_yaml)
17 17 update("UPDATE articles set %s WHERE id = %d" % [setting, article.id])
18 18 end
19 19 end
... ...
db/migrate/20110706171330_fix_misunderstood_script_filename.rb
... ... @@ -2,7 +2,7 @@
2 2 # from the migration fall on a loop and breaks the migration. Both them are
3 3 # related to alias_method_chain, probably there is a problem with this kind of
4 4 # alias on the migration level.
5   -class Article < ActiveRecord::Base
  5 +class Article < ApplicationRecord
6 6 def sanitize_tag_list
7 7 end
8 8 end
... ...
db/migrate/20110824192153_add_activated_at_to_users.rb
... ... @@ -2,7 +2,7 @@ class AddActivatedAtToUsers &lt; ActiveRecord::Migration
2 2 def self.up
3 3 add_column :users, :activation_code, :string, :limit => 40
4 4 add_column :users, :activated_at, :datetime
5   - if ActiveRecord::Base.connection.adapter_name == 'SQLite'
  5 + if ApplicationRecord.connection.adapter_name == 'SQLite'
6 6 execute "update users set activated_at = datetime();"
7 7 else
8 8 execute "update users set activated_at = now();"
... ...
db/migrate/20140724134601_fix_yaml_encoding.rb
1 1 class FixYamlEncoding < ActiveRecord::Migration
2 2 def self.up
3   - ActiveRecord::Base.transaction do
  3 + ApplicationRecord.transaction do
4 4 fix_encoding(Environment, 'settings')
5 5 fix_encoding(Profile, 'data')
6 6 fix_encoding(Product, 'data')
... ...
db/migrate/20150216213259_create_profile_activity.rb
1 1 class CreateProfileActivity < ActiveRecord::Migration
2 2 def up
3   - ActiveRecord::Base.transaction do
  3 + ApplicationRecord.transaction do
4 4 create_table :profile_activities do |t|
5 5 t.integer :profile_id
6 6 t.integer :activity_id
... ...
lib/activities_counter_cache_job.rb
1 1 class ActivitiesCounterCacheJob
2 2  
3 3 def perform
4   - person_activities_counts = ActiveRecord::Base.connection.execute("SELECT profiles.id, count(action_tracker.id) as count FROM profiles LEFT OUTER JOIN action_tracker ON profiles.id = action_tracker.user_id WHERE (action_tracker.created_at >= #{ActiveRecord::Base.connection.quote(ActionTracker::Record::RECENT_DELAY.days.ago.to_s(:db))}) AND ( (profiles.type = 'Person' ) ) GROUP BY profiles.id;")
5   - organization_activities_counts = ActiveRecord::Base.connection.execute("SELECT profiles.id, count(action_tracker.id) as count FROM profiles LEFT OUTER JOIN action_tracker ON profiles.id = action_tracker.target_id WHERE (action_tracker.created_at >= #{ActiveRecord::Base.connection.quote(ActionTracker::Record::RECENT_DELAY.days.ago.to_s(:db))}) AND ( (profiles.type = 'Community' OR profiles.type = 'Enterprise' OR profiles.type = 'Organization' ) ) GROUP BY profiles.id;")
  4 + person_activities_counts = ApplicationRecord.connection.execute("SELECT profiles.id, count(action_tracker.id) as count FROM profiles LEFT OUTER JOIN action_tracker ON profiles.id = action_tracker.user_id WHERE (action_tracker.created_at >= #{ApplicationRecord.connection.quote(ActionTracker::Record::RECENT_DELAY.days.ago.to_s(:db))}) AND ( (profiles.type = 'Person' ) ) GROUP BY profiles.id;")
  5 + organization_activities_counts = ApplicationRecord.connection.execute("SELECT profiles.id, count(action_tracker.id) as count FROM profiles LEFT OUTER JOIN action_tracker ON profiles.id = action_tracker.target_id WHERE (action_tracker.created_at >= #{ApplicationRecord.connection.quote(ActionTracker::Record::RECENT_DELAY.days.ago.to_s(:db))}) AND ( (profiles.type = 'Community' OR profiles.type = 'Enterprise' OR profiles.type = 'Organization' ) ) GROUP BY profiles.id;")
6 6 activities_counts = person_activities_counts.entries + organization_activities_counts.entries
7 7 activities_counts.each do |count|
8   - update_sql = ActiveRecord::Base.__send__(:sanitize_sql, ["UPDATE profiles SET activities_count=? WHERE profiles.id=?;", count['count'].to_i, count['id'] ], '')
9   - ActiveRecord::Base.connection.execute(update_sql)
  8 + update_sql = ApplicationRecord.__send__(:sanitize_sql, ["UPDATE profiles SET activities_count=? WHERE profiles.id=?;", count['count'].to_i, count['id'] ], '')
  9 + ApplicationRecord.connection.execute(update_sql)
10 10 end
11 11 Delayed::Job.enqueue(ActivitiesCounterCacheJob.new, {:priority => -3, :run_at => 1.day.from_now})
12 12 end
... ...
lib/acts_as_customizable.rb
... ... @@ -122,4 +122,4 @@ module Customizable
122 122 end
123 123 end
124 124  
125   -ActiveRecord::Base.send(:include, Customizable)
  125 +ApplicationRecord.send :include, Customizable
... ...
lib/acts_as_filesystem.rb
... ... @@ -33,7 +33,7 @@ module ActsAsFileSystem
33 33 module ClassMethods
34 34  
35 35 def build_ancestry(parent_id = nil, ancestry = '')
36   - ActiveRecord::Base.transaction do
  36 + ApplicationRecord.transaction do
37 37 self.base_class.where(parent_id: parent_id).each do |node|
38 38 node.update_column :ancestry, ancestry
39 39  
... ... @@ -263,5 +263,5 @@ module ActsAsFileSystem
263 263 end
264 264 end
265 265  
266   -ActiveRecord::Base.extend ActsAsFileSystem::ActsMethods
  266 +ApplicationRecord.extend ActsAsFileSystem::ActsMethods
267 267  
... ...
lib/acts_as_having_boxes.rb
... ... @@ -35,4 +35,4 @@ module ActsAsHavingBoxes
35 35  
36 36 end
37 37  
38   -ActiveRecord::Base.extend(ActsAsHavingBoxes::ClassMethods)
  38 +ApplicationRecord.extend ActsAsHavingBoxes::ClassMethods
... ...
lib/acts_as_having_image.rb
... ... @@ -23,4 +23,5 @@ module ActsAsHavingImage
23 23  
24 24 end
25 25  
26   -ActiveRecord::Base.extend(ActsAsHavingImage::ClassMethods)
  26 +ApplicationRecord.extend ActsAsHavingImage::ClassMethods
  27 +
... ...
lib/acts_as_having_posts.rb
... ... @@ -47,4 +47,5 @@ module ActsAsHavingPosts
47 47  
48 48 end
49 49  
50   -ActiveRecord::Base.extend(ActsAsHavingPosts::ClassMethods)
  50 +ApplicationRecord.extend ActsAsHavingPosts::ClassMethods
  51 +
... ...
lib/acts_as_having_settings.rb
... ... @@ -87,4 +87,5 @@ module ActsAsHavingSettings
87 87  
88 88 end
89 89  
90   -ActiveRecord::Base.send(:extend, ActsAsHavingSettings::ClassMethods)
  90 +ApplicationRecord.extend ActsAsHavingSettings::ClassMethods
  91 +
... ...
lib/code_numbering.rb
... ... @@ -55,4 +55,4 @@ module CodeNumbering
55 55 end
56 56 end
57 57  
58   -ActiveRecord::Base.extend CodeNumbering::ClassMethods
  58 +ApplicationRecord.extend CodeNumbering::ClassMethods
... ...
lib/delayed_attachment_fu.rb
... ... @@ -52,4 +52,5 @@ module DelayedAttachmentFu
52 52 end
53 53 end
54 54  
55   -ActiveRecord::Base.send(:extend, DelayedAttachmentFu::ClassMethods)
  55 +ApplicationRecord.extend DelayedAttachmentFu::ClassMethods
  56 +
... ...
lib/noosfero/core_ext.rb
1 1 require 'noosfero/core_ext/string'
2 2 require 'noosfero/core_ext/integer'
3   -require 'noosfero/core_ext/active_record'
  3 +require 'noosfero/core_ext/active_record/calculations'
4 4 require 'noosfero/core_ext/active_record/reflection'
5 5  
... ...
lib/noosfero/core_ext/active_record.rb
... ... @@ -1,74 +0,0 @@
1   -require 'active_record'
2   -
3   -class ActiveRecord::Base
4   -
5   - def self.postgresql?
6   - ActiveRecord::Base.connection.adapter_name == 'PostgreSQL'
7   - end
8   -
9   - # an ActionView instance for rendering views on models
10   - def self.action_view
11   - @action_view ||= begin
12   - view_paths = ::ActionController::Base.view_paths
13   - action_view = ::ActionView::Base.new view_paths
14   - # for using Noosfero helpers inside render calls
15   - action_view.extend ::ApplicationHelper
16   - action_view
17   - end
18   - end
19   -
20   - # default value needed for the above ActionView
21   - def to_partial_path
22   - self.class.name.underscore
23   - end
24   -
25   - alias :meta_cache_key :cache_key
26   - def cache_key
27   - key = [Noosfero::VERSION, meta_cache_key]
28   - key.unshift(ActiveRecord::Base.connection.schema_search_path) if ActiveRecord::Base.postgresql?
29   - key.join('/')
30   - end
31   -
32   - def self.like_search(query, options={})
33   - if defined?(self::SEARCHABLE_FIELDS) || options[:fields].present?
34   - fields_per_table = {}
35   - fields_per_table[table_name] = (options[:fields].present? ? options[:fields] : self::SEARCHABLE_FIELDS.keys.map(&:to_s)) & column_names
36   -
37   - if options[:joins].present?
38   - join_asset = options[:joins].to_s.classify.constantize
39   - if defined?(join_asset::SEARCHABLE_FIELDS) || options[:fields].present?
40   - fields_per_table[join_asset.table_name] = (options[:fields].present? ? options[:fields] : join_asset::SEARCHABLE_FIELDS.keys.map(&:to_s)) & join_asset.column_names
41   - end
42   - end
43   -
44   - query = query.downcase.strip
45   - fields_per_table.delete_if { |table,fields| fields.blank? }
46   - conditions = fields_per_table.map do |table,fields|
47   - fields.map do |field|
48   - "lower(#{table}.#{field}) LIKE '%#{query}%'"
49   - end.join(' OR ')
50   - end.join(' OR ')
51   -
52   - if options[:joins].present?
53   - joins(options[:joins]).where(conditions)
54   - else
55   - where(conditions)
56   - end
57   -
58   - else
59   - raise "No searchable fields defined for #{self.name}"
60   - end
61   - end
62   -
63   -end
64   -
65   -ActiveRecord::Calculations.class_eval do
66   - def count_with_distinct column_name=self.primary_key
67   - if column_name
68   - distinct.count_without_distinct column_name
69   - else
70   - count_without_distinct
71   - end
72   - end
73   - alias_method_chain :count, :distinct
74   -end
lib/noosfero/core_ext/active_record/calculations.rb 0 → 100644
... ... @@ -0,0 +1,10 @@
  1 +ActiveRecord::Calculations.class_eval do
  2 + def count_with_distinct column_name=self.primary_key
  3 + if column_name
  4 + distinct.count_without_distinct column_name
  5 + else
  6 + count_without_distinct
  7 + end
  8 + end
  9 + alias_method_chain :count, :distinct
  10 +end
... ...
lib/noosfero/multi_tenancy.rb
... ... @@ -12,12 +12,12 @@ module Noosfero
12 12 def self.db_by_host=(host)
13 13 if host != @db_by_host
14 14 @db_by_host = host
15   - ActiveRecord::Base.connection.schema_search_path = self.mapping[host]
  15 + ApplicationRecord.connection.schema_search_path = self.mapping[host]
16 16 end
17 17 end
18 18  
19 19 def self.setup!(host)
20   - if Noosfero::MultiTenancy.on? and ActiveRecord::Base.postgresql?
  20 + if Noosfero::MultiTenancy.on? and ApplicationRecord.postgresql?
21 21 Noosfero::MultiTenancy.db_by_host = host
22 22 end
23 23 end
... ...
lib/noosfero/unicorn.rb
... ... @@ -7,11 +7,11 @@ GC.respond_to?(:copy_on_write_friendly=) and
7 7 GC.copy_on_write_friendly = true
8 8  
9 9 before_fork do |server, worker|
10   - ActiveRecord::Base.connection.disconnect! if defined?(ActiveRecord::Base)
  10 + ApplicationRecord.connection.disconnect! if defined?(ApplicationRecord)
11 11 end
12 12  
13 13 after_fork do |server, worker|
14   - ActiveRecord::Base.establish_connection if defined?(ActiveRecord::Base)
  14 + ApplicationRecord.establish_connection if defined?(ApplicationRecord)
15 15 end
16 16  
17 17 # load local configuration file, if it exists
... ...
lib/postgresql_attachment_fu.rb
... ... @@ -9,11 +9,12 @@ module PostgresqlAttachmentFu
9 9 module InstanceMethods
10 10 def full_filename(thumbnail = nil)
11 11 file_system_path = (thumbnail ? thumbnail_class : self).attachment_options[:path_prefix].to_s
12   - file_system_path = File.join(file_system_path, ActiveRecord::Base.connection.schema_search_path) if ActiveRecord::Base.postgresql? and Noosfero::MultiTenancy.on?
  12 + file_system_path = File.join(file_system_path, ApplicationRecord.connection.schema_search_path) if ApplicationRecord.postgresql? and Noosfero::MultiTenancy.on?
13 13 Rails.root.join(file_system_path, *partitioned_path(thumbnail_name_for(thumbnail))).to_s
14 14 end
15 15 end
16 16  
17 17 end
18 18  
19   -ActiveRecord::Base.send(:extend, PostgresqlAttachmentFu::ClassMethods)
  19 +ApplicationRecord.extend PostgresqlAttachmentFu::ClassMethods
  20 +
... ...
lib/split_datetime.rb
... ... @@ -69,4 +69,5 @@ module SplitDatetime
69 69 end
70 70  
71 71 Class.extend SplitDatetime::SplitMethods
72   -ActiveRecord::Base.extend SplitDatetime::SplitMethods
  72 +ApplicationRecord.extend SplitDatetime::SplitMethods
  73 +
... ...
lib/sqlite_extension.rb
1   -if ActiveRecord::Base.connection.adapter_name.downcase == 'sqlite'
  1 +if ApplicationRecord.connection.adapter_name.downcase == 'sqlite'
2 2  
3   - database = ActiveRecord::Base.connection.raw_connection
  3 + database = ApplicationRecord.connection.raw_connection
4 4  
5 5 database.create_function('pow', 2, 1) do |func, base, exponent|
6 6 func.set_result(base.to_f ** exponent.to_f)
7 7 end
8   -
  8 +
9 9 database.create_function('sqrt', 1, 1) do |func, value|
10 10 func.set_result(Math.sqrt(value))
11 11 end
... ... @@ -18,8 +18,8 @@ if ActiveRecord::Base.connection.adapter_name.downcase == &#39;sqlite&#39;
18 18 func.set_result(
19 19 radius.to_f * Math.acos(
20 20 [1,
21   - Math.cos(lat1.to_f) * Math.cos(long1.to_f) * Math.cos(lat2.to_f) * Math.cos(long2.to_f) +
22   - Math.cos(lat1.to_f) * Math.sin(long1.to_f) * Math.cos(lat2.to_f) * Math.sin(long2.to_f) +
  21 + Math.cos(lat1.to_f) * Math.cos(long1.to_f) * Math.cos(lat2.to_f) * Math.cos(long2.to_f) +
  22 + Math.cos(lat1.to_f) * Math.sin(long1.to_f) * Math.cos(lat2.to_f) * Math.sin(long2.to_f) +
23 23 Math.sin(lat1.to_f) * Math.sin(lat2.to_f)
24 24 ].min
25 25 )
... ...
lib/tasks/backup.rake
... ... @@ -115,7 +115,7 @@ end
115 115  
116 116 desc 'Removes emails from database'
117 117 task 'restore:remove_emails' => :environment do
118   - connection = ActiveRecord::Base.connection
  118 + connection = ApplicationRecord.connection
119 119 [
120 120 "UPDATE users SET email = concat('user', id, '@localhost.localdomain')",
121 121 "UPDATE environments SET contact_email = concat('environment', id, '@localhost.localdomain')",
... ...
lib/tasks/multitenancy.rake
1 1 namespace :multitenancy do
2 2  
3 3 task :create => :environment do
4   - db_envs = ActiveRecord::Base.configurations.keys.select{ |k| k.match(/_development$|_production$|_test$/) }
  4 + db_envs = ApplicationRecord.configurations.keys.select{ |k| k.match(/_development$|_production$|_test$/) }
5 5 cd Rails.root.join('config', 'environments'), :verbose => true
6 6 file_envs = Dir.glob "{*_development.rb,*_production.rb,*_test.rb}"
7 7 (db_envs.map{ |e| e + '.rb' } - file_envs).each { |env| ln_s env.split('_').last, env }
8 8 end
9 9  
10 10 task :remove => :environment do
11   - db_envs = ActiveRecord::Base.configurations.keys.select{ |k| k.match(/_development$|_production$|_test$/) }
  11 + db_envs = ApplicationRecord.configurations.keys.select{ |k| k.match(/_development$|_production$|_test$/) }
12 12 cd Rails.root.join('config', 'environments'), :verbose => true
13 13 file_envs = Dir.glob "{*_development.rb,*_production.rb,*_test.rb}"
14 14 (file_envs - db_envs.map{ |e| e + '.rb' }).each { |env| safe_unlink env }
... ... @@ -19,7 +19,7 @@ end
19 19 namespace :db do
20 20  
21 21 task :migrate_other_environments => :environment do
22   - envs = ActiveRecord::Base.configurations.keys.select{ |k| k.match(/_#{Rails.env}$/) }
  22 + envs = ApplicationRecord.configurations.keys.select{ |k| k.match(/_#{Rails.env}$/) }
23 23 envs.each do |e|
24 24 puts "*** Migrating #{e}" if Rake.application.options.trace
25 25 system "rake db:migrate RAILS_ENV=#{e} SCHEMA=/dev/null"
... ...
lib/upload_sanitizer.rb
... ... @@ -10,4 +10,4 @@ module UploadSanitizer
10 10 end
11 11 end
12 12  
13   -ActiveRecord::Base.send(:include, UploadSanitizer)
  13 +ApplicationRecord.send :include, UploadSanitizer
... ...
plugins/analytics/models/analytics_plugin/page_view.rb
1   -class AnalyticsPlugin::PageView < ActiveRecord::Base
  1 +class AnalyticsPlugin::PageView < ApplicationRecord
2 2  
3 3 serialize :data
4 4  
... ...
plugins/analytics/models/analytics_plugin/visit.rb
1   -class AnalyticsPlugin::Visit < ActiveRecord::Base
  1 +class AnalyticsPlugin::Visit < ApplicationRecord
2 2  
3 3 attr_accessible *self.column_names
4 4 attr_accessible :profile
... ...
plugins/comment_classification/lib/comment_classification_plugin/comment_label_user.rb
1   -class CommentClassificationPlugin::CommentLabelUser < ActiveRecord::Base
  1 +class CommentClassificationPlugin::CommentLabelUser < ApplicationRecord
2 2 self.table_name = :comment_classification_plugin_comment_label_user
3 3  
4 4 belongs_to :profile
... ...
plugins/comment_classification/lib/comment_classification_plugin/comment_status_user.rb
1   -class CommentClassificationPlugin::CommentStatusUser < ActiveRecord::Base
  1 +class CommentClassificationPlugin::CommentStatusUser < ApplicationRecord
2 2 self.table_name = :comment_classification_plugin_comment_status_user
3 3  
4 4 belongs_to :profile
... ...
plugins/comment_classification/lib/comment_classification_plugin/label.rb
1   -class CommentClassificationPlugin::Label < ActiveRecord::Base
  1 +class CommentClassificationPlugin::Label < ApplicationRecord
2 2  
3 3 belongs_to :owner, :polymorphic => true
4 4  
... ...
plugins/comment_classification/lib/comment_classification_plugin/status.rb
1   -class CommentClassificationPlugin::Status < ActiveRecord::Base
  1 +class CommentClassificationPlugin::Status < ApplicationRecord
2 2  
3 3 belongs_to :owner, :polymorphic => true
4 4  
... ...
plugins/custom_forms/db/migrate/20130823151900_associate_fields_to_alternatives.rb
1 1 class AssociateFieldsToAlternatives < ActiveRecord::Migration
2   - class CustomFormsPlugin::Field < ActiveRecord::Base
  2 + class CustomFormsPlugin::Field < ApplicationRecord
3 3 self.table_name = :custom_forms_plugin_fields
4 4 has_many :alternatives, :class_name => 'CustomFormsPlugin::Alternative'
5 5 serialize :choices, Hash
... ...
plugins/custom_forms/lib/custom_forms_plugin/alternative.rb
1   -class CustomFormsPlugin::Alternative < ActiveRecord::Base
  1 +class CustomFormsPlugin::Alternative < ApplicationRecord
2 2 self.table_name = :custom_forms_plugin_alternatives
3 3  
4 4 validates_presence_of :label
... ...
plugins/custom_forms/lib/custom_forms_plugin/answer.rb
1   -class CustomFormsPlugin::Answer < ActiveRecord::Base
  1 +class CustomFormsPlugin::Answer < ApplicationRecord
2 2 self.table_name = :custom_forms_plugin_answers
3 3 belongs_to :field, :class_name => 'CustomFormsPlugin::Field'
4 4 belongs_to :submission, :class_name => 'CustomFormsPlugin::Submission'
... ...
plugins/custom_forms/lib/custom_forms_plugin/field.rb
1   -class CustomFormsPlugin::Field < ActiveRecord::Base
  1 +class CustomFormsPlugin::Field < ApplicationRecord
2 2 self.table_name = :custom_forms_plugin_fields
3 3  
4 4 validates_presence_of :name
... ...
plugins/custom_forms/lib/custom_forms_plugin/form.rb
1   -class CustomFormsPlugin::Form < ActiveRecord::Base
  1 +class CustomFormsPlugin::Form < ApplicationRecord
2 2  
3 3 belongs_to :profile
4 4  
... ...
plugins/custom_forms/lib/custom_forms_plugin/submission.rb
1   -class CustomFormsPlugin::Submission < ActiveRecord::Base
  1 +class CustomFormsPlugin::Submission < ApplicationRecord
2 2  
3 3 belongs_to :form, :class_name => 'CustomFormsPlugin::Form'
4 4 belongs_to :profile
... ...