Hi all, Just letting you know we have a new DSL for Action Mailer. class Notifier < ActionMailer::Base delivers_from("system-hcDgGtZH8xNBDgjK7y7TUQ@public.gmane.org") def signup_notification(recipient) @account = recipient attachments[''an-image.jp''] = File.read("an-image.jpg") attachments[''terms.pdf''] = {:content => generate_your_pdf_here() } mail(:to => recipient.email_address_with_name, :subject => "New account information") end end Notifier.signup_notification(recipient).deliver You can read all about it at: http://lindsaar.net/2010/1/26/new-actionmailer-api-in-rails-3 Mikel -- http://lindsaar.net/ -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Nice. I''m not sure I understand the new API though. You define instance methods but call class methods? Also, what''s that magic recipient parameter we never pass in? Why not just define class methods? Eg: class Notifier < ActionMailer::Base delivers_from("system@example.com") def self.signup_notification(recipient) @account = recipient attachments[''an-image.jp''] = File.read("an-image.jpg") attachments[''terms.pdf''] = {:content => generate_your_pdf_here() } mail(:to => recipient.email_address_with_name, :subject => "New account information") end end And then do something like Notifier.signup_notification(user).deliver Cheers -foca On Tue, Jan 26, 2010 at 12:29 AM, Mikel Lindsaar <raasdnil@gmail.com> wrote:> Hi all, > > Just letting you know we have a new DSL for Action Mailer. > > class Notifier < ActionMailer::Base > delivers_from("system@example.com") > > def signup_notification(recipient) > @account = recipient > > attachments[''an-image.jp''] = File.read("an-image.jpg") > attachments[''terms.pdf''] = {:content => generate_your_pdf_here() } > > mail(:to => recipient.email_address_with_name, > :subject => "New account information") > end > end > > Notifier.signup_notification(recipient).deliver > > You can read all about it at: > > http://lindsaar.net/2010/1/26/new-actionmailer-api-in-rails-3 > > Mikel > > > -- > http://lindsaar.net/ > > -- > You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. > To post to this group, send email to rubyonrails-core@googlegroups.com. > To unsubscribe from this group, send email to rubyonrails-core+unsubscribe@googlegroups.com. > For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en. > >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-core+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en.
2010/1/26 Nicolás Sanguinetti <godfoca@gmail.com>:> Nice.Thanks :)> I''m not sure I understand the new API though. You define instance > methods but call class methods? Also, what''s that magic recipient > parameter we never pass in? Why not just define class methods? Eg:Class methods won''t work unfortunately, this is because you can''t play with instance variables or call other instance methods (like headers or attachments) I am not sure what the magic recipient parameter is we never pass in. If you are talking about the old API doing: recipients recipient.email_address_with_name This is replaced with mail(:to => recipient.email_address_with_name) Mikel --- http://lindsaar.net/ -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-core+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en.
Nice work! On Jan 25, 9:29 pm, Mikel Lindsaar <raasd...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hi all, > > Just letting you know we have a new DSL for Action Mailer. > > class Notifier < ActionMailer::Base > delivers_from("sys...-hcDgGtZH8xNBDgjK7y7TUQ@public.gmane.org") > > def signup_notification(recipient) > @account = recipient > > attachments[''an-image.jp''] = File.read("an-image.jpg") > attachments[''terms.pdf''] = {:content => generate_your_pdf_here() } > > mail(:to => recipient.email_address_with_name, > :subject => "New account information") > end > end > > Notifier.signup_notification(recipient).deliver > > You can read all about it at: > > http://lindsaar.net/2010/1/26/new-actionmailer-api-in-rails-3 > > Mikel > > --http://lindsaar.net/-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org 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.
Have you seen this: http://gist.github.com/281420 On Jan 25, 2010, at 6:29 PM, Mikel Lindsaar wrote:> > Hi all, > > Just letting you know we have a new DSL for Action Mailer. > > class Notifier < ActionMailer::Base > delivers_from("system-hcDgGtZH8xNBDgjK7y7TUQ@public.gmane.org") > > def signup_notification(recipient) > @account = recipient > > attachments[''an-image.jp''] = File.read("an-image.jpg") > attachments[''terms.pdf''] = {:content => generate_your_pdf_here() } > > mail(:to => recipient.email_address_with_name, > :subject => "New account information") > end > end > > Notifier.signup_notification(recipient).deliver > > You can read all about it at: > > http://lindsaar.net/2010/1/26/new-actionmailer-api-in-rails-3 > > Mikel-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
I think he means in your blog post, you have samples like this: Notifier.signup_notification.deliver Ie. calling the signup_notification class method with no arguments. And yet what you showed defined in the Notifier class was an instance method expecting a parameter that you''ve named recipient in your examples: def signup_notification(recipient) I was wondering the same thing, where is that recipient argument coming from? On Jan 25, 2010, at 8:10 PM, Mikel Lindsaar wrote:> 2010/1/26 Nicolás Sanguinetti <godfoca@gmail.com>: >> Nice. > > Thanks :) > >> I''m not sure I understand the new API though. You define instance >> methods but call class methods? Also, what''s that magic recipient >> parameter we never pass in? Why not just define class methods? Eg: > > Class methods won''t work unfortunately, this is because you can''t play > with instance variables or call other instance methods (like headers > or attachments) > > I am not sure what the magic recipient parameter is we never pass in. > If you are talking about the old API doing: > > recipients recipient.email_address_with_name > > This is replaced with > > mail(:to => recipient.email_address_with_name) > > Mikel > > --- > http://lindsaar.net/ > > -- > You received this message because you are subscribed to the Google > Groups "Ruby on Rails: Core" group. > To post to this group, send email to rubyonrails- > core@googlegroups.com. > To unsubscribe from this group, send email to rubyonrails-core+unsubscribe@googlegroups.com > . > For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en > . >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-core+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en.
On Tue, Jan 26, 2010 at 6:09 PM, Jason King <smathy.werp@gmail.com> wrote:> I think he means in your blog post, you have samples like this: > > Notifier.signup_notification.deliver > def signup_notification(recipient) > > I was wondering the same thing, where is that recipient argument coming > from?Ahh... thanks, updated the post to be clear :) Mikel -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-core+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en.
On Tue, Jan 26, 2010 at 5:56 PM, steve ross <cwdinfo-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Have you seen this: http://gist.github.com/281420Of course, that was the result of the discussion in campfire we had that hashed out the new DSL that José and I implemented :) One change on that though is that delivers_from is not there, and it is replaced with a defaults hash. -- http://lindsaar.net/ -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org 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.
> Just letting you know we have a new DSL for Action Mailer.I think removing the magic #deliver_* and #create_* methods, and returning an actual Mail object directly by an existing method makes a lot of sense. On the other hand, I think replacing methods like #body, #subject, etc. with a hash is a missed idea, it''s harder to write and read, and less clear to grasp, especially when you notice that ActiveRecord API changes in exactly the opposite direction (from :conditions => conditions to #where(conditions), etc.). Are there any more improvements planned on this or is that the final version? -- Bye, Olek -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Tue, Jan 26, 2010 at 10:29 PM, Olek <olek.janiszewski-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On the other hand, I think replacing methods like #body, #subject, > etc. with a hash is a missed idea, it''s harder to write and read, and > less clear to grasp, especially when you notice that ActiveRecord API > changes in exactly the opposite direction (from :conditions => > conditions to #where(conditions), etc.). > > Are there any more improvements planned on this or is that the final > version?You don''t have to pass body as a hash, you pass the body in through the template in 99% of the cases. Think of the mail method as being analogous to the respond_to method in Action Controller. There are more changes coming, not big, but intelligent ones. Watch this space :) -- http://lindsaar.net/ -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
BTW, Awesome work Mikel! On Jan 25, 2010, at 11:10 PM, Mikel Lindsaar wrote:> 2010/1/26 Nicolás Sanguinetti <godfoca@gmail.com>: >> Nice. > > Thanks :) > >> I''m not sure I understand the new API though. You define instance >> methods but call class methods? Also, what''s that magic recipient >> parameter we never pass in? Why not just define class methods? Eg: > > Class methods won''t work unfortunately, this is because you can''t play > with instance variables or call other instance methods (like headers > or attachments) > > I am not sure what the magic recipient parameter is we never pass in. > If you are talking about the old API doing: > > recipients recipient.email_address_with_name > > This is replaced with > > mail(:to => recipient.email_address_with_name) > > Mikel > > --- > http://lindsaar.net/ > > -- > You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. > To post to this group, send email to rubyonrails-core@googlegroups.com. > To unsubscribe from this group, send email to rubyonrails-core+unsubscribe@googlegroups.com. > For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en. >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To post to this group, send email to rubyonrails-core@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-core+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en.