3
我正在使用rails 3.0.4。我打算在保存学生记录后发送短信给特定号码。那我要提到的代码中轨下方2.X运作良好,但在轨道3.0.4,我得到一个错误:未初始化的常量Student :: Net
NameError in StudentsController#create
uninitialized constant Student::Net
代码:
def send_welcome_sms
url=URI.parse("http://webaddress.com");
#error occuring at this point
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) }
# If U are Behind The Proxy Comment Above Line And Uncomment Below Line, Give The Proxy Ip & Port
#response = Net::HTTP::Proxy("PROXY IP", PROXYPORT).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
你能斌的'StudentsController#create'代码? – Oleander 2011-05-29 10:59:12