I have a ruby on rails script that I run by issuing the command: sudo
ruby
script/mailman_serverThe contents of this file are:
#!/usr/bin/env rubyrequire "rubygems"require "bundler/setup"require
"mailman"require "rb-inotify"require “#{File.dirname
FILE}/…/config/environment”
Mailman.config.maildir = ‘/var/mail’
Mailman::Application.run do
default do
begin
# call a model
Bin.receive_mail(message)
end
endend
I get an error saying:
E, [2013-03-15T02:06:39.555346 #6351] ERROR – : uninitialized constant
Bin/var/www/beebin/script/mailman_server:14
Bin is a model and receive_mail() is a function in that model. Why can’t
my
script see the model? PS: I’ve also tried starting the script multiple
other ways sometimes it sporadically working:
sudo bundle exec script/mailman_server
sudo bundle exec rails runner script/mailman_server
sudo bundle exec ruby script/mailman_ctl stop
I feel like the rails environment isn’t loading properly. What am I
missing
from the code or what is the best way to start the app?