actionmailer - Define_method rails mailer -


is possible write mailer methods define_method,because need similar methods,like notify_user_approved & notify_user_rejected

   %w(approved rejected).each do|meth|       define_method("notify_user_#{meth}") |user,subject|         @url = user.email         @user = user         mail(to: @url, subject: subject)       end     end 

notification mailer class name

notification.notify_user_rejected(user.last,'approved').deliver_now 

i having nomethoderror: undefined methodmail' notification:class when try run mailer

whole class

class notification < actionmailer::base    %w(approved rejected).each do|meth|    define_method("notify_user_#{meth}") |user,subject|      @url = user.email      @user = user      mail(to: @url, subject: subject)    end  end end 


Comments