[Rails-core] Feature proposal: Silently skip add with before_add association callback using false

2015-08-04 Thread Bruno Macabeus
As stated in the documentation 
http://guides.rubyonrails.org/association_basics.html#association-callbacks: 
*If a before_add callback throws an exception, the object does not get 
added to the collection*

This way to prevent that save is very ugly.
It would be better to keep the standard of the other callback (like 
before_create): if it returns false, not saved.
Others users would also like it that way 
http://stackoverflow.com/questions/7273792/silently-skip-add-with-before-add-association-callback-instead-of-raising-an-exc
.

-- 
You received this message because you are subscribed to the Google Groups Ruby 
on Rails: Core group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to rubyonrails-core+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-core@googlegroups.com.
Visit this group at http://groups.google.com/group/rubyonrails-core.
For more options, visit https://groups.google.com/d/optout.


Re: [Rails-core] Feature proposal: Silently skip add with before_add association callback using false

2015-08-04 Thread Rafael Mendonça França
Thank you for the suggestion.

All callbacks now are only skipped if an exception is raised and we are
removing the special meaning of false, so I think this behavior correct.

On Tue, Aug 4, 2015 at 4:48 PM Bruno Macabeus bruno.macab...@gmail.com
wrote:

 As stated in the documentation
 http://guides.rubyonrails.org/association_basics.html#association-callbacks:
 *If a before_add callback throws an exception, the object does not get
 added to the collection*

 This way to prevent that save is very ugly.
 It would be better to keep the standard of the other callback (like
 before_create): if it returns false, not saved.
 Others users would also like it that way
 http://stackoverflow.com/questions/7273792/silently-skip-add-with-before-add-association-callback-instead-of-raising-an-exc
 .

 --
 You received this message because you are subscribed to the Google Groups
 Ruby on Rails: Core group.
 To unsubscribe from this group and stop receiving emails from it, send an
 email to rubyonrails-core+unsubscr...@googlegroups.com.
 To post to this group, send email to rubyonrails-core@googlegroups.com.
 Visit this group at http://groups.google.com/group/rubyonrails-core.
 For more options, visit https://groups.google.com/d/optout.


-- 
You received this message because you are subscribed to the Google Groups Ruby 
on Rails: Core group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to rubyonrails-core+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-core@googlegroups.com.
Visit this group at http://groups.google.com/group/rubyonrails-core.
For more options, visit https://groups.google.com/d/optout.