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 ?
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).
On Wed, Mar 31, 2010 at 5:28 PM, Andion <and...@gmail.com> wrote: > 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!
> -- > To unsubscribe, reply using "remove me" as the subject.
> 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).
> On Wed, Mar 31, 2010 at 5:28 PM, Andion <and...@gmail.com> wrote: > > 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!
> > -- > > To unsubscribe, reply using "remove me" as the subject.
On Wed, Mar 31, 2010 at 6:25 PM, Andion <and...@gmail.com> wrote: > 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: > > 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).
> > On Wed, Mar 31, 2010 at 5:28 PM, Andion <and...@gmail.com> wrote: > > > 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)
> > > ... 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!
> > > -- > > > To unsubscribe, reply using "remove me" as the subject.
> 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?
> On Wed, Mar 31, 2010 at 6:25 PM, Andion <and...@gmail.com> wrote: > > 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: > > > 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).
> > > On Wed, Mar 31, 2010 at 5:28 PM, Andion <and...@gmail.com> wrote: > > > > 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)
> > > > ... 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!
> > > > -- > > > > To unsubscribe, reply using "remove me" as the subject.
On Wed, Mar 31, 2010 at 6:39 PM, Andion <and...@gmail.com> wrote: > 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: > > 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?
> > On Wed, Mar 31, 2010 at 6:25 PM, Andion <and...@gmail.com> wrote: > > > 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: > > > > 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).
> > > > On Wed, Mar 31, 2010 at 5:28 PM, Andion <and...@gmail.com> wrote: > > > > > 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)
> > > > > ... 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!
> > > > > -- > > > > > To unsubscribe, reply using "remove me" as the subject.
> 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?
> On Wed, Mar 31, 2010 at 6:39 PM, Andion <and...@gmail.com> wrote: > > 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: > > > 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?
> > > On Wed, Mar 31, 2010 at 6:25 PM, Andion <and...@gmail.com> wrote: > > > > 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: > > > > > 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).
> > > > > On Wed, Mar 31, 2010 at 5:28 PM, Andion <and...@gmail.com> wrote: > > > > > > 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)
> > > > > > ... 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!
> > > > > > -- > > > > > > To unsubscribe, reply using "remove me" as the subject.
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:
> On Mar 31, 6:53 pm, José Valim <jose.va...@gmail.com> wrote:
> > 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?
> > On Wed, Mar 31, 2010 at 6:39 PM, Andion <and...@gmail.com> wrote: > > > 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: > > > > 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?
> > > > On Wed, Mar 31, 2010 at 6:25 PM, Andion <and...@gmail.com> wrote: > > > > > 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: > > > > > > 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).
> > > > > > On Wed, Mar 31, 2010 at 5:28 PM, Andion <and...@gmail.com> wrote: > > > > > > > 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)
> > > > > > > ... 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!
> > > > > > > -- > > > > > > > To unsubscribe, reply using "remove me" as the subject.
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:
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:
> 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:
> > Yes :/
> > On Mar 31, 6:53 pm, José Valim <jose.va...@gmail.com> wrote:
> > > 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?
> > > On Wed, Mar 31, 2010 at 6:39 PM, Andion <and...@gmail.com> wrote: > > > > 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: > > > > > 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?
> > > > > On Wed, Mar 31, 2010 at 6:25 PM, Andion <and...@gmail.com> wrote: > > > > > > 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: > > > > > > > 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).
> > > > > > > On Wed, Mar 31, 2010 at 5:28 PM, Andion <and...@gmail.com> wrote: > > > > > > > > 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)
> > > > > > > > ... 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!
> > > > > > > > -- > > > > > > > > To unsubscribe, reply using "remove me" as the subject.
> > > > > > > -- > > > > > > > José Valim
> > > > > > > Director of Engineering - Plataforma Tecnologia > > > > > > > Know more about us:http://plataformatec.com.br/en/