Forum: Rails Germany ActionMailer Error ActionView::TemplateError

Posted by Rails Camper (railscamper)
on 2009-05-20 12:10
(Received via mailing list)
Hallo Freunde,

ich versuche gerade die Daten in eine Email zu bekommen.

der AthletMailer sieht so aus

[...]
def welcome_email(athlet)
      @recipients   = "ich@me.com"

      @from         = "Registrierung <schroedi2001>"
      @subject      = " Neuer Teilnehmer angemeldet"
      sent_on       Time.now
      body           :athlet => athlet
      content_type  "text/html"

Das klappt auch soweit und ich kann Mails verschicken. Nur jetzt 
würdeich gerne den Inhalt des @athlet in meiner Email auslesen ähnlich wie in
einer View

Allerdings schmeisst mir das immer einen Fehler

      Es hat sich ein neuer Teilnehmer angemeldet.  <%=
@athlet.first_name %>.<br/>

NoMethodError in Athlets#create

Showing app/views/athlet_mailer/welcome_email.erb where line #9 raised:

You have a nil object when you didn't expect it!
The error occurred while evaluating nil.first_name
Extracted source (around line #9):

6:   <body>
7:     <h1>Neuer Teilnehmer angemeldet <%#=h @athlet %></h1>
8:     <p>
9:       Es hat sich ein neuer Teilnehmer angemeldet.  <%=
@athlet.first_name %>.<br/>
10:
11:       <%= Time.now %>
12:     </p>

Jemand ein paar Tipps, wie ich mir heute den Tag versüssen könnte?

Mario

--

Mario Schröder | http://www.ironschroedi.com/de/
Office: +49 361 2152062
Phone: +49 34464 62301 Cell: +49 163 27 09 807
http://www.xing.com/go/invite/6035007.9c143c
Posted by Maximilian Schulz (namxam)
on 2009-05-20 12:27
(Received via mailing list)
hi,

also gute Frage. An für sich sieht das vollkommen richtig aus (obwohl
ich nicht weiß warum du Methodenaufrufe mit Instanzvariablen mischst).
Bist du denn sicher, dass du deiner deliver_welcome_mail methode auch
wirklich einen Athleten mitgibst? Liegt ja vielleicht gar nicht an der
mail-view ;)

Max
Posted by Rails Camper (railscamper)
on 2009-05-20 12:34
(Received via mailing list)
class Athlet < ActiveRecord::Base
  after_create :notify_user
  def notify_user
  AthletMailer.deliver_welcome_email(@athlet)
  end
end

hmmmmmm.....


Maximilian Schulz wrote:
> schroedi wrote:
>>        @from         = "Registrierung<schroedi2001>"
>>        Es hat sich ein neuer Teilnehmer angemeldet.<%=
>> 6:<body>
>> Mario
>>
>>    
> _______________________________________________
> rubyonrails-ug mailing list
> rubyonrails-ug@headflash.com
> http://mailman.headflash.com/listinfo/rubyonrails-ug
>

--

Mario Schröder | http://www.ironschroedi.com/de/
Office: +49 361 2152062
Phone: +49 34464 62301 Cell: +49 163 27 09 807
http://www.xing.com/go/invite/6035007.9c143c
Posted by Mathias Meyer (mattmatt)
on 2009-05-20 12:37
(Received via mailing list)
2009/5/20 schroedi <schroedi2001@gmail.com>:
>
> class Athlet < ActiveRecord::Base
>  after_create :notify_user
>  def notify_user
>  AthletMailer.deliver_welcome_email(@athlet)
>  end
> end
>
class Athlet < ActiveRecord::Base
  after_create :notify_user
  def notify_user
    AthletMailer.deliver_welcome_email(self)
  end
end
Posted by Rails Camper (railscamper)
on 2009-05-20 12:43
(Received via mailing list)
kleine ursache große wirkung

danke mathias

Mathias Meyer wrote:
> class Athlet < ActiveRecord::Base
>   
--

Mario Schröder | http://www.ironschroedi.com/de/
Office: +49 361 2152062
Phone: +49 34464 62301 Cell: +49 163 27 09 807
http://www.xing.com/go/invite/6035007.9c143c
Please log in before posting. Registration is free and takes only a minute.
Existing account (Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
No account? Register here.