How customize confirmation instructions mailler

1,790 views
Skip to first unread message

Breno Perucchi

unread,
Jul 16, 2010, 7:41:51 PM7/16/10
to Devise
I would like customize the confirmation instructions mail that devise
send when the user are create. I need customize the subject and email
from

Breno

charper

unread,
Jul 18, 2010, 8:37:25 AM7/18/10
to Devise
Run this in your rails app folder to generate views which you can
edit :

rails generate devise:views


On Jul 17, 12:41 am, Breno Perucchi <bperuc...@gmail.com> wrote:
> I would like customize theconfirmationinstructions mail that devisesendwhen the user are create. I need customize the subject and email
> from
>
> Breno

tehael

unread,
Jul 19, 2010, 6:29:42 AM7/19/10
to Devise

for rails-3.0.0.beta4 with devise-1.1.rc2

_ the subject can be customized by editing the appropriate keys
config/locales/devise.en.yml
default key is 'devise.mailer.confirmation_instructions.subject'
note it's is possible to set model-specific subjects by adding a
corresponding key
devise.mailer.confirmation_instructions.user_subject'

_ the mail-from can be set in config/initializers/devise.rb by editing
config.mailer_sender = "please-change-me@config-initializers-
devise.com"

Breno Perucchi

unread,
Jul 20, 2010, 3:48:25 PM7/20/10
to Devise
thanks Tehael

But I can change the subject in the some controller, like as
user_controller.rb

I would like to change subject when call before create. I could do
this?

before.create do
APP_CONFIG = YAML.load_file(File.join("#{Rails.root}/config/locales,
"en", "devise.en.yml"))
APP_CONFIG.devise.sessions.confirmation_intrusctions = "test"

but how I load devise initializer in the controller to change the
mailer sender?

end

Breno Perucchi

unread,
Jul 21, 2010, 10:58:08 AM7/21/10
to Devise
I made!

I extend the devise Controller in my user_controller.rb

User_controller.rb
extend Devise::Controllers::InternalHelpers::ScopedViews

create.before do
Devise.mailer_sender = "confirmacao@#{current_domain.gsub(":
3000","")}"
end

Devise.rb
@config = YAML.load_file(File.join(Rails.root, "config", "locales",
"devise.pt_BR.yml"))

Devise.setup do |config|
# Configure the e-mail address which will be shown in
DeviseMailer.
config.mailer_sender = @config['pt_BR']['devise']['config']
['devise_sender']
end

Devise.pt_BR.yml
pt_BR:
devise:
config:
devise_sender: 'confi...@xxx.com.br'
Reply all
Reply to author
Forward
0 new messages