Note that there are some explanatory texts on larger screens.

plurals
  1. POUser Mailer Failing
    primarykey
    data
    text
    <p>I have setup a process in my User model to send a bunch of @users to a mailing script, user_mailer.rb</p> <p>I am using the <a href="http://postageapp.com" rel="nofollow noreferrer">http://postageapp.com</a> app to send out emails. The users are getting to the User_mailer but I am getting an error from there. Can anyone please point me in the right direction.</p> <p>User Model:</p> <pre><code>class User &lt; ActiveRecord::Base acts_as_authentic def self.mail_out weekday = Date.today.strftime('%A').downcase @users = find(:all, :conditions =&gt; {"#{weekday}sub".to_sym =&gt; 't'}) UserMailer.deliver_mail_out(@users) end end </code></pre> <p>User_mailer.rb</p> <pre><code>class UserMailer &lt; ActionMailer::Base def mail_out(users) @recipients = { } users.each do |user| @recipients[user.email] = { :zipcode =&gt; user.zipcode } end from "no-reply@dailytrailer.net" subject "Check out the trailer of the day!" body :user =&gt; user end end </code></pre> <p>mail_out.html.erb</p> <pre><code>{{zipcode}}, Please check out the trailer of the day at http://www.dailytrailer.net Thank you! -- The DailyTrailer.net Team </code></pre> <p>User db schema</p> <pre><code> create_table "users", :force =&gt; true do |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; false t.string "tuesdaysub", :default =&gt; "f", :null =&gt; false t.string "wednesdaysub", :default =&gt; "f", :null =&gt; false t.string "thursdaysub", :default =&gt; "f", :null =&gt; false t.string "fridaysub", :default =&gt; "f", :null =&gt; false t.string "saturdaysub", :default =&gt; "f", :null =&gt; false t.string "sundaysub", :default =&gt; "f", :null =&gt; false end </code></pre> <p>Error:</p> <pre><code>/var/lib/gems/1.8/gems/rails-2.3.5/lib/commands/runner.rb:48: undefined method `name' for #&lt;User:0xb6e8ae48&gt; (NoMethodError) from /home/tnederlof/Dropbox/Ruby/daily_trailer/app/models/user_mailer.rb:5:in `mail_out' from /home/tnederlof/Dropbox/Ruby/daily_trailer/app/models/user_mailer.rb:4:in `each' from /home/tnederlof/Dropbox/Ruby/daily_trailer/app/models/user_mailer.rb:4:in `mail_out' from /home/tnederlof/.gem/ruby/1.8/gems/actionmailer-2.3.5/lib/action_mailer/base.rb:459:in `__send__' from /home/tnederlof/.gem/ruby/1.8/gems/actionmailer-2.3.5/lib/action_mailer/base.rb:459:in `create!' from /home/tnederlof/.gem/ruby/1.8/gems/actionmailer-2.3.5/lib/action_mailer/base.rb:452:in `initialize' from /home/tnederlof/.gem/ruby/1.8/gems/actionmailer-2.3.5/lib/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:in `method_missing' from /home/tnederlof/Dropbox/Ruby/daily_trailer/app/models/user.rb:13:in `mail_out' from (eval):1 from /usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in `eval' from /var/lib/gems/1.8/gems/rails-2.3.5/lib/commands/runner.rb:48 from /usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require' from /usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in `require' from script/runner:3 </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload