Devise with scoped views is not rendering the right mailer views

592 views
Skip to first unread message

sippndipp

unread,
Feb 11, 2013, 3:57:16 PM2/11/13
to plataforma...@googlegroups.com
Hi,

I'm using devise (2.2.0) with scoped views. Unfortunately Devise is not using the correct mailer views - instead
it's using the ones of the gem. The controllers all work fine.

Did I do something wrong with the configuration (scoped_views is true).

Thanks

Sebastian

Lucas Mazza

unread,
Feb 14, 2013, 7:05:23 AM2/14/13
to plataforma...@googlegroups.com
Sebastian, 

how is the directory structure for your views? Is it something like "app/views/user/mailer/confirmation_instructions" ? Any more info/code can help.


--
 
---
You received this message because you are subscribed to the Google Groups "Devise" group.
To unsubscribe from this group and stop receiving emails from it, send an email to plataformatec-de...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

sippndipp

unread,
Feb 14, 2013, 8:44:36 AM2/14/13
to plataforma...@googlegroups.com
Hi Lucas,

yes I've generated the views (including the mailer templates via the rake task). These are my Routes:

namespace :dashboard do
  devise_for :apprentices
  devise_for :companies
end

The regular views will be taken from dashboard/apprentices but not the mailer views. I've managed to work around the problem
by moving the mailer templates to devise/mailer and inside these templates I've checking for the type of the resource.

Thanks for your help.

Sebastian

Lucas Mazza

unread,
Feb 14, 2013, 8:47:35 AM2/14/13
to plataforma...@googlegroups.com
Yeah, I don't think that the namespace in the routes file affect the Mailers, unless they are proper namespaced (but I guess you aren't using a custom mailer). Does placing the views in app/apprentices/mailer works?


Sebastian

sippndipp

unread,
Feb 14, 2013, 8:53:42 AM2/14/13
to plataforma...@googlegroups.com
Unfortunately not. If I place the mailer dir inside the apprentice dir then the mailer templates from the gem will be used. As mentioned earlier if I place them inside a devise directory the right ones are taken. I'm not using a custom mailer. I assume it's a bug with the scoped_views = true flag.
To unsubscribe from this group and stop receiving emails from it, send an email to plataformatec-devise+unsub...@googlegroups.com.

sippndipp

unread,
Feb 14, 2013, 9:42:21 AM2/14/13
to plataforma...@googlegroups.com
Actually I was not 100% precise before. Out of SEO reasons I'm using devise_for with many parameters:

devise_for :apprentices, path: 'azubi', singular: 'apprentice', module: 'dashboard/azubi'

I took a look in the devise mappings path in lib/devise/mailers/helper.rb

@devise_mapping.scoped_path

is returning dashboard/apprentice. For some reason it works with the views - but the singular "apprentice" is more a hack than a solution.
I try to refactor it in another way.

Thanks for you help

Best

Sebastian



On Thursday, February 14, 2013 2:47:35 PM UTC+1, Lucas Mazza wrote:
To unsubscribe from this group and stop receiving emails from it, send an email to plataformatec-devise+unsub...@googlegroups.com.

sippndipp

unread,
Feb 17, 2013, 8:36:47 AM2/17/13
to plataforma...@googlegroups.com
Hi,

I boiled down the problem to the following scenario:

Since the options[:module] just affects the controllers but not the mailer the mailer will just look at "devise/mailer" and "MODEL_NAME/mailer".

To fix that I've created a bugfix branch where I store the module parameter in an instance variable:


All tests are passing, but maybe you can help me to develop a test case for that.

Best

Sebastian


On Thursday, February 14, 2013 2:47:35 PM UTC+1, Lucas Mazza wrote:
To unsubscribe from this group and stop receiving emails from it, send an email to plataformatec-devise+unsub...@googlegroups.com.

Lucas Mazza

unread,
Feb 17, 2013, 2:23:14 PM2/17/13
to plataforma...@googlegroups.com
Testing this might be a little tricky - you might need to add a new model to the dummy app in test/rails_app with a `devise_scope` with a specific module option, since the mailer tests won't pick up a new scope with an already used model. 

A Pull Request (even without tests) can provide some better feedback on how to test this.
To unsubscribe from this group and stop receiving emails from it, send an email to plataformatec-de...@googlegroups.com.

sippndipp

unread,
Feb 17, 2013, 2:57:08 PM2/17/13
to plataforma...@googlegroups.com
Thanks for the tip. I guess an easier test would be to just check if the template_paths yields the correct pathes.
I'll work on it now.

Best

Sebastian
To unsubscribe from this group and stop receiving emails from it, send an email to plataformatec-devise+unsubscrib...@googlegroups.com.

For more options, visit https://groups.google.com/groups/opt_out.
 
 
Reply all
Reply to author
Forward
Message has been deleted
0 new messages