I am working on rails 3.0.4. I am going to send sms to a specific number after saving the student record. The code that I will discuss below works well in rails 2.X, but on rails 3.0.4 I get an error message:
NameError in StudentsController
uninitialized constant Student::Net
the code:
def send_welcome_sms
url=URI.parse("http://webaddress.com");
request = Net::HTTP::Post.new(url.path)
message = "message goes here"
request.set_form_data({'username'=>"abc", 'password'=>"xyz", 'to'=> "some number", 'text'=> "#{message}", 'from'=> "someone"})
response = Net::HTTP.new(url.host, url.port).start {|http| http.request(request) }
case response
when Net::HTTPSuccess
puts response.body
else
response.body
response.error!
end
end
source
share