我正在尝试将对象(用户)发送到 NotificationsMailer,如下所示:
pry(main)>NotificationsMailer.welcome_facebook_user({:password=>'123',:email=>'as453now@gmail.com',:basic_profile=>{:name=>'Samir'}}).deliver
但我得到了这个错误:
ActionView::Template::Error: undefined method `basic_profile' for #<Hash:0x0000000786d588>
from /app/app/views/notifications_mailer/welcome_facebook_user.html.haml:2:in `block in _app_views_notifications_mailer_welcome_facebook_user_html_haml__4104442834642741128_62933320'
NotificationsMailer.welcome_facebook_user:
def welcome_facebook_user(user)
@user = user
puts "SENT welcome_facebook_user TO:"
puts user[:email]
mail(:to=>user[:email], :subject => "Welcome!")
end
我的模板:
=content_for :title do
Welcome, #{@user.basic_profile.name unless @user.basic_profile.nil?}
在现实世界:
用户.rb
class User < Refinery::Core::BaseModel
has_one :basic_profile
但是,我想用 pry 测试它,如何发送这样的用户对象?为什么我的尝试失败了?