ruby on rails - User Mailer Failing -
I send a user module in a user model to a mailing script, user_mailer.bb
I am using the app to send emails The user is accessing User_mailer but I am getting an error from there Anyone can point me in the right direction.
User model:
class users & lt; ActiveRecord :: Base acts_s_totic def self.mail_out weekday = date.light. ('% a'). DownCase @ User = Search (All :: Terms => {"# {Workday} Sub" .to_sym = & gt; 'T'}) UserMailer.deliver_mail_out (@users) Ends
User_mailer.rb
Class UserMailer & lt; ActionMailer :: Base def mail_out (user) @recipients = {} users.each do | User | @recipients [user.email] = {: zipcode = & gt; User.zipcode} "no -reply@dailytrailer.net" ends with "see the trailer of the day"! Body: user = & gt; End of user end
mail_out.html.erb
{{zipcode}}, please see day trailer on http: // www Dailytrailer Net thanks! - Delaterrarennet Team
User DB Schema
create_table "users" ,: force = & gt; Is true T | T.string "email" t.date "birthday" t.string "gender" t.string "zipcode" t.datetime "created_at" t.datetime "updated_at" t.string "crypted_password" t.string "password_salt" t. String "persistence_token" t.string "mondaysub" ,: default = & gt; "F" ,: null = & gt; Wrong t.string "tuesdaysub" ,: default = & gt; "F" ,: null = & gt; False t String "wednesdaysub" ,: default => "F" ,: null = & gt; Wrong t.string "thursdaysub" ,: default = & gt; "F" ,: null = & gt; Wrong t.string "fridaysub" ,: default = & gt; "F" ,: null = & gt; Wrong t.string "saturdaysub" ,: default => "F" ,: null = & gt; Wrong t.string "sundaysub" ,: default = & gt; "F" ,: null = & gt; Wrong end
error:
/var/lib/gems/1.8/gems/rails-2.3.5/lib/commands/runner.rb: 48: Exceptioned method # Name for user name: 0xb6e8ae48 & gt; (NoMethodError) from '/home/tnederlof/Dropbox/Ruby/daily_trailer/app/models/user_mailer.rb:4 from /home/tnederlof/Dropbox/Ruby/daily_trailer/app/models/user_mailer.rb:5:in `mail_out `each /home/tnederlof/.gem/ruby/1.8/gems/actionmailer-2.3 in '/home/tnederlof/Dropbox/Ruby/daily_trailer/app/models/user_mailer.rb:4:in Se` mail_out'. 5 / lib / action_mailer / base.rb: 459: /home/tnederlof/.gem/ruby/1.8/gems/actionmailer-2.3.5/lib/action_mailer/base.rb in `/ __send__ ': 459: Making in` From! Starting with `/home/tnederlof/.gem/ruby/1.8/gems/ '/home/tnederlof/.gem/ruby/1.8/gems/actionmailer-2.3.5/lib/action_mailer/base.rb:452:in 'ActionMailer-2.3.3 / Leib / Action_Mailer / Base. RB: 395: in `new 'from /home/tnederlof/.gem/ruby/1.8/gems/actionmailer-2.3.5/lib/action_mailer/base.rb:395: /usr/lib/ruby/1.8/rubygems/ 1 custom_require: `(eval) from '/home/tnederlof/Dropbox/Ruby/daily_trailer/app/models/user.rb: 13: in` .rb in' method_missing the mail_out: 31:` / var / lib / gems In 'eval' from /1.8/gems/rails-2.3.5/lib/commands/runner.rb:48 /usr/lib/ruby/1.8/rubygems/custom_require rb: 31: `gem_original_require require '/usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in Se` script / runner': 3
I'm not sure whether this is the complete solution (what error are you getting?), But there is something that is going to fix Need: line body: user = & gt; User
, user
variable is not defined. Do you mean to do this : user = & gt; @recipients
?
Comments
Post a Comment