ruby on rails - Weird object issue when trying to render partial from mailer view -


using rails 3. per first snippet of code below, it's hard google search error means when trying render partial mailer view.

this error:

actionview::template::error (undefined method `long_date' #<#<class:0x00000102452ab0>:0x00000102440b30>): 

here's mailer view (email_note.html.erb)

<div style="width:500px;">   <%= render :partial => "shared/note", :object => @note %> </div> 

this call i'm making in partial throwing error <%= long_date(note.created_at) %>

long_date has worked when have given partial @note objects other actions (e.g. 'show' in notes_controller). method

def long_date(date)   date.strftime('%a %b %e, %g') end 

here actionmailer class (address , note_id sent 'email' action in notes_controller)

class usermailer < actionmailer::base  default :from => "gminett@gmail.com"    def email_note(address,note_id)     @note = note.find(note_id)     mail(:to => "#{address}", :subject => "note repository: #{@note.subject}")   end end 

seems me rails (very due oversight on part) not interpreting @note object note class, don't know how fix it. appreciated.

this because default actionmailer templates don't share same helpers actionview ones do. if need use helpers in mailer templates try including module in actionmailer class:

include datetimehelper 

Comments

Popular posts from this blog

php - What is the difference between $_SERVER['PATH_INFO'] and $_SERVER['ORIG_PATH_INFO']? -

fortran - Function return type mismatch -

queue - mq_receive: message too long -