Thursday, May 17, 2012

[Rails] Two layouts in one mailer

Hi all,

I'm having problems figuring out how to know which mailer method is being invoked in the layout callback.

In my controller, I have code like this and its working great:

class Users::RegistrationsController < Devise::RegistrationsController
    layout :devise_or_application

    def devise_or_application
        ["edit", "update", "destroy"].include?(params[:action]) ? "application" : "devise"
    end
end

Now I need the same thing for my mailer, but params[:action] is not available in mailers. Is there another way to use different layout in one mailer, based on which mailer method is being called, like above?

Mailer in question is a custom Devise mailer (inheriting from default Devise mailer), so I can't really use different mailer, as Devise allows me to configure only one mailer to be used.

Thanks in advance!

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/PpBVgHVsbY8J.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate