Hey Leute,
bevor wieder ein paar GErüchte aufkommen in Sachen Finanzkrise und Co.
Ich habe die eine oder andere Frage zum ActionMailer.
Ausgangslage:
Ich lege über den Athlet Controller einen Athleten an und will nach dem
erfolgreichen speichern eine Email an mich und ihn verschicken lassen.
AthletController:
def create
@athlet = Athlet.new(params[:athlet])
respond_to do |format|
if @athlet.save
flash[:notice] = 'Athlet was successfully created.'
format.html { redirect_to(@athlet) }
format.xml { render :xml => @athlet, :status => :created,
:location => @athlet }
else
format.html { render :action => “new” }
format.xml { render :xml => @athlet.errors, :status =>
:unprocessable_entity }
end
end
end
Athlet Model
class Athlet < ActiveRecord::Base
after_create :notify_user
end
AthletMailer:
class AthletMailer < ActionMailer::Base
after_create :notify_user
def notify_user
AthletMailer.deliver_welcome_email(user)
end
def welcome_email(user)
recipients user.email
from “My Awesome Site
Notifications[email protected]”
subject “Welcome to My Awesome Site”
sent_on Time.now
body {:user => user, :url => “http://example.com/login”}
content_type “text/html”
# use some_other_template.text.(html|plain).erb instead
template “some_other_template”
end
def welcome(user)
@recipients athlet.email
@subject = “TEST User Anmeldung”
end
end
Aber irgendwie bin ich wohl zu doof dafür. Ich bekomme in jeglicher Form
immer den Fehler
undefined method `notify_user’ for #Athlet:0x23609c8
Hat jemand mal ein Bild oder Struktorgramm, dass ich sehen kann wo der
Fehler liegt oder kann mir jemand helfen…?
Thanx
mario
–
Mario Schröder | http://www.ironschroedi.com/de/
Office: +49 361 2152062
Phone: +49 34464 62301 Cell: +49 163 27 09 807
Willkommen bei XING! | XING