ruby on rails - Locale not working when called from a rake task -


i have rails app (2.3.8) send emails using actionmailer controllers, no problems.

however, i´ve created rake task called cronjob (in heroku). when emails sent, no locale transformations in dates made.

i´ve googled find kind of solution, couldn´t.

anyone can me?

thanks.

here code:

cron.rake:

desc 'this task called heroku cron add-on'   task :cron => :environment   puts 'sending diary...'   hollydays = [6,0] #weekend     unless hollydays.member?(time.zone.now.wday) #if not weekend     user.all.each |user|      user.deliver_task_diary  end   end   puts 'done.'   end   

user model method:

def deliver_task_diary   taskmailer.deliver_task_diary(self) end 

the method in taskmailer model:

def task_diary(user)   next_five_tasks = user.next_five_tasks   last_five_tasks = user.last_five_tasks    recipients "#{user.name} <#{user.email}>"         "my site <no_reply@mysite.com>"   subject    "your daily tasks."   sent_on    time.zone.now   body       :user => user, :next_five_tasks => next_five_tasks, :last_five_tasks => last_five_tasks 

end

part of email template doesn´t locale:

<%=l task.estimated_delivery_date, :format => :short %> 

solved.

i don´t know if it´s best way, i´ve declared locale @ beging of email html template:

<% i18n.locale = "pt-br" %> 

Comments

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -