Reputation: 430
In my controller I am trying to execute a ruby script:
def mymethod
variable = `ruby /home/user/Test.rb`
exec variable
raise "Failed: #{variable}" unless variable.blank?
end
Test.rb script is present in the mentioned path, even then i get an error:
Errno::ENOENT (No such file or directory - )
The Test.rb content:
require 'rubygems'
require 'net/smtp'
require 'pp'
require 'mysql'
require 'yaml'
message = "MESSAGE_END
G Name <MyEmailAddress>
To: G Name <MyEmailAddress>
Subject: SMTP e-mail test
This is a test mail"
Net::SMTP.start('webserver') do |smtp|
smtp.send_message message, 'EmailAddress', 'EmailAddress'
end
When I manually run this script. It sends the mail as expected.
Upvotes: 1
Views: 8955
Reputation: 2273
You have to
require 'open-uri'
So,
require '/home/user/Test.rb'
require 'open-uri' # sometimes without this line, we get the exact error message in ruby on rails..
(or)
Try to reboot your server, sometimes its fix it..
Upvotes: 1