Render :partial in mail template


#1

Hi,

Is it possible to render a partial template from within a mail template?
I get the following error

undefined method `controller_path’ for SupportMailer:Class

Extracted source (around line #8):

5:
6: <%= @url %>
7:
8: <%= render_partial ‘sig_admin’ %>

Jeroen


#2

On Nov 17, 2005, at 8:38 AM, Jeroen H. wrote:

5:
6: <%= @url %>
7:
8: <%= render_partial ‘sig_admin’ %>

Could you file this as a bug on dev.rubyonrails.com? It looks like I
need to do a bit more work to make ActionMailer quack like an
ActionController…

  • Jamis

#3

On 11/17/05, Jamis B. removed_email_address@domain.invalid wrote:

Extracted source (around line #8):

5:
6: <%= @url %>
7:
8: <%= render_partial ‘sig_admin’ %>

Could you file this as a bug on dev.rubyonrails.com? It looks like I
need to do a bit more work to make ActionMailer quack like an
ActionController…

Anyone know the status of this? I’m running into the same problem
using Rails 1.0.


#4

Hi Joe,
An unrelated question … I am trying to use action mailer but I am
having
problems with the views … Where exactly do the variables in the view
come
from .For example in your code you use @url. Is this an instance
variable
you created in your Mailer < ActionMailer::Base ?
Thanks
Vivek


#5

On 12/30/05, Joe Van D. removed_email_address@domain.invalid wrote:

ActionController…

Anyone know the status of this? I’m running into the same problem
using Rails 1.0.

I tried to search dev.rubyonrails.org but couldn’t figure out how to
search the bug list. I tried filtering, but clicking the ‘plus’
filter button didn’t seem to do anything remotely useful.


#6

I am trying to use action mailer but I am having problems with the
views … Where exactly do the variables in the view come from .For
example in your code you use @url. Is this an instance variable you
created in your Mailer < ActionMailer::Base ?

They’re defined either as instance variables, or as hash parameters
to the render_message() function. For your reference, a large snippet
from the top of the ActionMailer::Base docs:

class ApplicationMailer < ActionMailer::Base
# Set up properties
# Properties can also be specified via accessor methods
# (i.e. self.subject = “foo”) and instance variables (@subject =
“foo”).
def signup_notification(recipient)
recipients recipient.email_address_with_name
subject “New account information”
body { “account” => recipient }
from “removed_email_address@domain.invalid”
end

 # explicitly specify multipart messages
 def signup_notification(recipient)
   recipients      recipient.email_address_with_name
   subject         "New account information"
   from            "removed_email_address@domain.invalid"

   part :content_type => "text/html",
     :body => render_message("signup-as-html", :account =>

recipient)

   part "text/plain" do |p|
     p.body = render_message("signup-as-plain", :account =>

recipient)
p.transfer_encoding = “base64”
end
end

-Ben


#7

Hi all,

I am creating a ruby app which allows users to request changes to the
DB. The requests will be routed to the DBA and the DBA will authorize
it. So far good. No issues. The issue arises when I want to give the
DBA an option of migrating the changes to other schemas as well. How do
I have more than one schema mapped to one app?

Thanks.


saleem


#8

On 12/30/05, Vivek K. removed_email_address@domain.invalid wrote:

Hi Joe,
An unrelated question … I am trying to use action mailer but I am having
problems with the views … Where exactly do the variables in the view come
from .For example in your code you use @url. Is this an instance variable
you created in your Mailer < ActionMailer::Base ?

In whatever Mailer action you’re working with, put

@body[:url] = whatever a url is

Then, in the views, you’ll have access to the @url instance variable.