Skip to content

Instantly share code, notes, and snippets.

@dawidof
Last active September 10, 2015 17:27
Show Gist options
  • Save dawidof/d91e3ffe17c9533c4a2f to your computer and use it in GitHub Desktop.
Save dawidof/d91e3ffe17c9533c4a2f to your computer and use it in GitHub Desktop.
module Responder
class Broadcast < ActiveRecord::Base
has_many :broadcast_actions
has_many :sent_messages, as: :supplier
has_many :sms_sents, as: :supplier
has_many :subscriber_list_items, as: :item
has_many :subscriber_lists, through: :subscriber_list_items
validates :name, presence: true, uniqueness: true
accepts_nested_attributes_for :broadcast_actions
scope :active, -> { where(paused: false) }
scope :not_deleted, -> { where('deleted_at IS NULL') }
def self.search(search)
if search
where('name LIKE ?', "%#{search}%").order(id: :desc)
else
all.order(id: :desc)
end
end
amoeba do
enable
prepend :name => "Copy of "
include_association :broadcast_actions
end
end
end
production
#<User id: 1, email: "somemail@gmail.com", encrypted_password: "$2a$10$kw7GSUyen6NVrYNjAPx9lOUYgeBnV7B3g2bKhelMDrw...", reset_password_token: nil, reset_password_sent_at: nil, remember_created_at: "2015-09-10 14:01:46", sign_in_count: 8, current_sign_in_at: "2015-09-10 14:01:46", last_sign_in_at: "2015-09-10 12:49:26", current_sign_in_ip: "89.79.106.40", last_sign_in_ip: "89.79.106.40", failed_attempts: 0, unlock_token: nil, locked_at: nil, created_at: "2015-08-26 17:47:49", updated_at: "2015-09-10 14:01:46", name: "dawidof">
rake aborted!
NameError: uninitialized constant Responder::Broadcast
/home/dawidof/mailsender/lib/tasks/subscribers.rake:7:in `block (2 levels) in <top (required)>'
Tasks: TOP => subscribers:process_form_inputs
(See full trace by running task with --trace)
namespace :subscribers do
desc "Process form inputs"
task process_form_inputs: :environment do
puts Rails.env
puts User.first.inspect
puts Responder::Broadcast.first.inspect ## here is an error in production on the server
## some other code
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment