Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Customize Mailer views for different resource types
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  9 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Andion  
View profile  
 More options Mar 31 2010, 11:28 am
From: Andion <and...@gmail.com>
Date: Wed, 31 Mar 2010 08:28:38 -0700 (PDT)
Local: Wed, Mar 31 2010 11:28 am
Subject: Customize Mailer views for different resource types
Following the readme,I wanted to have customized mail views so I have
different mails for different resources (admin & user in my case) but
had no success:

1 - Using rails 3.0.0beta & devise 1.1.pre4
2 - I've created app/views/admins/mailer/ & app/views/users/mailer/
with my email personalizations > Doesn't work
3 - I've tested that scoped views are working by customizing sign_in
(sessions/new) views > Working

I've read devise code and I figured out (I don't know if correctly)
that the mapping should be to my devise_mapping.as set on
devise_for... but it's aready correct (tested with ActionView scoped
views working)

So...
  Devise::Mailer#setup_mail(record, action)
calls:
  render_with_scope(action, :controller => "mailer")
and there it renders the template with:
  render :template => "#{devise_mapping.as}/#{controller_name}/
#{action}"

... read that everything seems like in normal scoped views to me... so
I don't understand why it's not working: Anybody knows what obvious
point am I missing ?

Thanks!


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
José Valim  
View profile  
 More options Mar 31 2010, 11:34 am
From: José Valim <jose.va...@gmail.com>
Date: Wed, 31 Mar 2010 17:34:31 +0200
Local: Wed, Mar 31 2010 11:34 am
Subject: Re: [devise] Customize Mailer views for different resource types

Unfortunately it looks like a bug to me. This is definitely fixed on Devise
master, so you can either migrate to Devise master or live with the bug
until a new Devise gem be released (which will be right after a new Rails
beta is released).

--
José Valim

Director of Engineering - Plataforma Tecnologia
Know more about us: http://plataformatec.com.br/en/


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Andion  
View profile  
 More options Mar 31 2010, 12:25 pm
From: Andion <and...@gmail.com>
Date: Wed, 31 Mar 2010 09:25:26 -0700 (PDT)
Local: Wed, Mar 31 2010 12:25 pm
Subject: Re: Customize Mailer views for different resource types
Checked with devise master (015c74e) & rails master (db28d407) - still
have the exact same problem. This is what makes me think it's my
fault.

Somebody made personalized mail views and has some tips to share? :)

On Mar 31, 5:34 pm, José Valim <jose.va...@gmail.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
José Valim  
View profile  
 More options Mar 31 2010, 12:32 pm
From: José Valim <jose.va...@gmail.com>
Date: Wed, 31 Mar 2010 18:32:16 +0200
Local: Wed, Mar 31 2010 12:32 pm
Subject: Re: [devise] Re: Customize Mailer views for different resource types

In devise test suite, there is a Rails application inside test/rails_app/.
Maybe it can give you some hints?

Notice that there is a view at
test/rails_app/app/views/users/mailer/confirmation_instructions.erb.

Are you using mailer views with mime type like
confirmations_instructions.html.erb? Maybe this is the issue?

--
José Valim

Director of Engineering - Plataforma Tecnologia
Know more about us: http://plataformatec.com.br/en/


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Andion  
View profile  
 More options Mar 31 2010, 12:39 pm
From: Andion <and...@gmail.com>
Date: Wed, 31 Mar 2010 09:39:00 -0700 (PDT)
Subject: Re: Customize Mailer views for different resource types
I'm using mime_types, but they work: The problem is the mailer view
rendered is always from the 'user' resource scope.

I'll check the test/rails_app, thanks a lot :)

On Mar 31, 6:32 pm, José Valim <jose.va...@gmail.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
José Valim  
View profile  
 More options Mar 31 2010, 12:53 pm
From: José Valim <jose.va...@gmail.com>
Date: Wed, 31 Mar 2010 18:53:17 +0200
Local: Wed, Mar 31 2010 12:53 pm
Subject: Re: [devise] Re: Customize Mailer views for different resource types

So you have both app/views/users/mailer and app/views/admins/mailer?
And it's always picking up the first?

What `Devise.mappings` returns on console? Calling .as on the mappings are
returning the proper value?

--
José Valim

Director of Engineering - Plataforma Tecnologia
Know more about us: http://plataformatec.com.br/en/


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Andion  
View profile  
 More options Mar 31 2010, 1:05 pm
From: Andion <and...@gmail.com>
Date: Wed, 31 Mar 2010 10:05:25 -0700 (PDT)
Local: Wed, Mar 31 2010 1:05 pm
Subject: Re: Customize Mailer views for different resource types
Yes :/

On Mar 31, 6:53 pm, José Valim <jose.va...@gmail.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Andion  
View profile  
 More options Mar 31 2010, 1:28 pm
From: Andion <and...@gmail.com>
Date: Wed, 31 Mar 2010 10:28:40 -0700 (PDT)
Local: Wed, Mar 31 2010 1:28 pm
Subject: Re: Customize Mailer views for different resource types
I'm out until monday, then I'll check everything again using test/
rails_app to see if it's my code. Taking a look at it the only
difference seems the lack of mime-type on the mail layout. Thank's a
lot

On Mar 31, 7:05 pm, Andion <and...@gmail.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Andion  
View profile  
 More options Apr 7 2010, 6:37 am
From: Andion <and...@gmail.com>
Date: Wed, 7 Apr 2010 03:37:15 -0700 (PDT)
Local: Wed, Apr 7 2010 6:37 am
Subject: Re: Customize Mailer views for different resource types
I knew it must be my fault!

I'll explain my mistake, in case somebody was interested on this
thread: Views, as we stated here are scoped according using resource
mappings; i.e: if you have an 'user' an 'admin' devise models, then
you'll have a two different mappings more or less like this one:

>> y Devise.mappings[:admin]

--- !ruby/object:Devise::Mapping
as: :admins
controllers:
  :sessions: devise/sessions
klass: Admin
modules:
- :database_authenticatable
- :rememberable
- :validatable
- :timeoutable
- :trackable
name: :admin
path_names:
  :sign_in: sign_in
  :sign_out: sign_out
path_prefix: /
routes:
- :session
strategies:
- :rememberable
- :database_authenticatable
=> nil

So, we can have two possible resource types logged in, and on most
cases, this is what will make devise to render it's scoped view

  render :template => "#{devise_mapping.as}/#{controller_name}/"

Then I mixed it on my mind with my personal configuration (users can
sign_up or an admin may register them) and expect that when an admin
where creating the user, /admins/mailer/* views will be used. Stupid
mistake: setup_mail is called from devise model's after_save (when
using confirmable, for example) and the current_user, nor the request
has to do with it: so the mailer view always rendering was the one
from the model (user on this case)

Finally: Solution to my willings? I don't know, either not using
confirmable at all or personalize users mail view according to
current_user. This was what made me go through the wrong way at first,
because you can't use current_user or auth helpers like {resource}
_signed_in? on mail views cause they are apart from the
request :-/. ... any ideas, anybody?

PS: I have an ugly, *ugly* temporal solution but I don't recommend it,
if anyone's interested i'll post it here.

So thanks Jose for all your patience, and sorry for my mistake :-/

On 31 mar, 19:28, Andion <and...@gmail.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »