-
Hey @excid3, Using the suggested In config.to_prepare do
Noticed::Event.include Noticed::EventExtensions
Noticed::Notification.include Noticed::NotificationExtensions
end and the error is bin/rails aborted!
ActiveRecord::StatementInvalid: PG::UndefinedTable: ERROR: relation "noticed_notifications" does not exist (ActiveRecord::StatementInvalid)
LINE 10: WHERE a.attrelid = '"noticed_notifications"'::regclass
^
/home/phil/dev/ryalto/ryalto-v4/app/models/noticed/notification_extensions.rb:16:in `block (2 levels) in <module:NotificationExtensions>'
/home/phil/dev/ryalto/ryalto-v4/app/models/noticed/notification_extensions.rb:25:in `block in <module:NotificationExtensions>'
/home/phil/dev/ryalto/ryalto-v4/config/application.rb:44:in `include'
/home/phil/dev/ryalto/ryalto-v4/config/application.rb:44:in `block in <class:Application>'
/home/phil/dev/ryalto/ryalto-v4/config/environment.rb:5:in `<main>'
Caused by:
PG::UndefinedTable: ERROR: relation "noticed_notifications" does not exist (PG::UndefinedTable)
LINE 10: WHERE a.attrelid = '"noticed_notifications"'::regclass
^
/home/phil/dev/ryalto/ryalto-v4/app/models/noticed/notification_extensions.rb:16:in `block (2 levels) in <module:NotificationExtensions>'
/home/phil/dev/ryalto/ryalto-v4/app/models/noticed/notification_extensions.rb:25:in `block in <module:NotificationExtensions>'
/home/phil/dev/ryalto/ryalto-v4/config/application.rb:44:in `include'
/home/phil/dev/ryalto/ryalto-v4/config/application.rb:44:in `block in <class:Application>'
/home/phil/dev/ryalto/ryalto-v4/config/environment.rb:5:in `<main>'
Tasks: TOP => test:prepare => dartsass:build => environment
(See full trace by running task with --trace) Is there something that I should be doing differently? app/models/noticed/notification_extensions.rbmodule Noticed::NotificationExtensions
extend ActiveSupport::Concern
EXCLUDED_TYPES = %w[Call::EndedNotifier::Notification Call::StartedNotifier::Notification
NewMessageNotifier::Notification SwitchedOrganisationNotifier::Notification].freeze
included do
delegate :organisation, :action_type, :title, :body, :url, to: :event, allow_nil: true
delegate :id, :name, to: :organisation, prefix: true, allow_nil: true
scope :for_index_and_counts, -> { where.not(type: EXCLUDED_TYPES) }
scope :filter_by_org, ->(organisation_id) { joins(:event).where(event: { organisation_id: }) }
scope :filter_by_type, ->(type) { where(type:) }
scope :exclude_type, ->(type) { where.not(type:) }
counter_culture :recipient, column_name: proc { |n| n.include_in_counts? ? "notifications_count" : nil },
column_names: { Noticed::Notification.for_index_and_counts => :notifications_count }
counter_culture :recipient, column_name: proc { |n| 'unread_notifications_count' if n.read_at.nil? },
column_names: { Noticed::Notification.for_index_and_counts.unread => :unread_notifications_count }
end
end |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 26 replies
-
That error says you don't have a |
Beta Was this translation helpful? Give feedback.
-
Since |
Beta Was this translation helpful? Give feedback.
Strange. Maybe
to_prepare
runs earlier there because it's happening on application load. The reason we useto_prepare
is classes can be reloaded in development so we want to make sure those extensions are always applied in case Noticed models get reloaded.