Why can't the Mail block see my variable?

前端 未结 3 1531
生来不讨喜
生来不讨喜 2021-02-15 11:35

I\'m new to Ruby and wondering why I am getting an error in this situation using the \'mail\' gem in a simple Sinatra app:

post \"/email/send\" do

  @recipient          


        
3条回答
  •  广开言路
    2021-02-15 11:44

    I think it's because the Mail gem uses instance_exec under the hood. instance_exec uses instance variables from the object it's being called on and not from the caller. What I'd do is find a method in the Mail gem that does not use instance tricks but passes an explicit configuration object to the block, and proceed from there. Spares a few gray hairs.

提交回复
热议问题