Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/62.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails 为什么这个对象没有定义?Ruby、Rails、Gmail错误_Ruby On Rails_Ruby - Fatal编程技术网

Ruby on rails 为什么这个对象没有定义?Ruby、Rails、Gmail错误

Ruby on rails 为什么这个对象没有定义?Ruby、Rails、Gmail错误,ruby-on-rails,ruby,Ruby On Rails,Ruby,我似乎不明白我为什么会出错: 2017-01-03T02:57:35.239505+00:00 app[web.1]: I, [2017-01-03T02:57:35.239437 #4] INFO -- : [89b504ee-5835-4bfa-a3ff-91a3a84549f6] Parameters: {"id"=>"3"} 2017-01-03T02:57:35.243975+00:00 app[web.1]: D, [2017-01-03T02:57:35.243890

我似乎不明白我为什么会出错:

2017-01-03T02:57:35.239505+00:00 app[web.1]: I, [2017-01-03T02:57:35.239437 #4]  INFO -- : [89b504ee-5835-4bfa-a3ff-91a3a84549f6]   Parameters: {"id"=>"3"}
2017-01-03T02:57:35.243975+00:00 app[web.1]: D, [2017-01-03T02:57:35.243890 #4] DEBUG -- : [89b504ee-5835-4bfa-a3ff-91a3a84549f6]   User Load (1.5ms)  SELECT  "users".* FROM "users" WHERE "users"."id" = $1 ORDER BY "users"."id" ASC LIMIT $2  [["id", 22], ["LIMIT", 1]]
2017-01-03T02:57:35.468562+00:00 app[web.1]: true
2017-01-03T02:57:35.476648+00:00 app[web.1]: D, [2017-01-03T02:57:35.476563 #4] DEBUG -- : [89b504ee-5835-4bfa-a3ff-91a3a84549f6]   Blueprint Load (2.7ms)  SELECT  "blueprints".* FROM "blueprints" WHERE "blueprints"."id" = $1 LIMIT $2  [["id", 3], ["LIMIT", 1]]
2017-01-03T02:57:35.477654+00:00 app[web.1]: I, [2017-01-03T02:57:35.477582 #4]  INFO -- : [89b504ee-5835-4bfa-a3ff-91a3a84549f6] Completed 500 Internal Server Error in 238ms (ActiveRecord: 5.5ms)
2017-01-03T02:57:35.478257+00:00 app[web.1]: F, [2017-01-03T02:57:35.478177 #4] FATAL -- : [89b504ee-5835-4bfa-a3ff-91a3a84549f6]
2017-01-03T02:57:35.478313+00:00 app[web.1]: F, [2017-01-03T02:57:35.478256 #4] FATAL -- : [89b504ee-5835-4bfa-a3ff-91a3a84549f6] Gmail::Client::DeliveryError (Couldn't deliver email: undefined method `subject' for nil:NilClass):
出于某种原因,object@current\u blueprint在gmail.deliver块中似乎不起作用。我错过了什么明显的东西吗

谢谢你的帮助。谢谢

@current_blueprint = Blueprint.find(params[:id])
mail_status = gmail.deliver! do
  to "email@gmail.com"
  subject @current_blueprint.subject
  html_part do
    content_type 'text/html; charset=UTF-8'
    body @current_blueprint.body
  end
end
puts mail_status

请尝试在不使用
@
符号的情况下使用
current\u blueprint

有时,库使用不同的
self
执行
do end
,因此不能访问实例变量,但它应该能够访问范围内的局部变量


只是猜测一下,让我知道它是否有效。

这样做了-我知道它必须是简单的,因为它在控制台中正确执行-非常感谢!如果你想知道这是为什么或如何发生的,可以填写详细信息。谢谢你的帮助!