Quantcast
Channel: Active questions tagged ruby - Stack Overflow
Viewing all articles
Browse latest Browse all 4633

How to access specific model in rails config/production.rb file?

$
0
0

I want to send exception mail to email_ids stored in yb_notifier_email_ids table. Previously, email_id was hardcoded in production.rb file. I want to send mail by using model. But as configurations file are loaded before active_records I am not able to do this.

-----------migration

        class CreateYbNotifierEmailIds < ActiveRecord::Migration          def change            create_table :yb_notifier_email_ids do |t|              t.string :email_id              t.timestamps null: false            end          end        end

----------------------------required------------

        config.middleware.use ExceptionNotification::Rack,            :email => {              :email_prefix => "[YB] ",              :sender_address => %{"YB Notifier" <noreply@yb.com>},              :exception_recipients => YbNotifierEmailIds.pluck(:email_id)            }        end

-----------------------I have tried this:

        Rails.application.middleware.use ExceptionNotification::Rack,              :email => {                :email_prefix => "[YB-QA] ",                :sender_address => %{"YB Notifier" <noreply@yb.com>},                :exception_recipients => defined?(YbNotifierEmailId) && YbNotifierEmailId.table_exists? ? YbNotifierEmailIds.pluck(:email_id) : %w{test@ssolution.com}            }

but defined?(YbNotifierEmailId) && YbNotifierEmailId.table_exists? this condition is getting failed.


Viewing all articles
Browse latest Browse all 4633

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>