All pastes #561130 Raw Edit

Anonymous

public text v1 · immutable
·published 2007-06-12 10:56 UTC
rendered paste body
/views/my_mailer/newcomment.rhtml

<p>From: <%= @comment.name %></p>
<p>Email: <%= @comment.email %></p>
<p>Website: <%= @comment.website %></p>
<p><%= @comment.comment %></p>

<%= link_to "Moderate Comments", :controller=>"comments", :action=>"list" %>

/model/my_mailer.rb

class MyMailer < ActionMailer::Base
	def newcomment(comment, sent_at = Time.now)
		@headers["Organization"] = "Beilabs.com"
		@subject = 'MyMailer#confirm'
		@recipients = 'jonathan@beilabs.com'
		@from = 'server@beilabs.com'
		@sent_on = sent_at
		@headers = {}
		@body = {}
		@comment = comment
	end
end


/controller/comments_controller.rb
def create
    @comment = Comment.new(params[:comment])
    @comment.article_id=params[:id]
    if @comment.save
      MyMailer::deliver_newcomment(@comment)
      flash[:notice] = 'Comment was successfully created.'
      redirect_to :action => 'list'
    else
      render :action => 'new'
    end
  end