nolith / habtm-with-deferred-save
Rails plugin. Defers saving the records you add to habtm association until you call model.save, allowing validation in the style of normal attributes.
Clone this repository (size: 195.2 KB): HTTPS / SSH
$ hg clone http://code.l0g.in/habtm-with-deferred-save
| commit 9: | c7287bf557dd |
| parent 8: | d8a7e572f5cc |
| branch: | default |
FIX: delete all the assocation into the join table after obj.destroy
- View nolith's profile
-
nolith's public repos »
- yubiruby
- hgredmine
- dns_gen
- hgredmine-patch
- evetrader
- ipv6 - fine del mondo
- geany-stata
- scintilla-STATA
- habtm-with-deferred-save
- redirector
- avahiserve
- test
- macports
- darkcast
- redmine-bitbucket
- redmine-hg
- redmine-mq-issue4455
- About Me
- about-me-dev
- ldap
- intro_ipv6
- home_dir
- PortableNotary
- CaptureMJPEG
- ruby-beamer
- eveberry-bis
- Send message
7 months ago
Changed (Δ140 bytes):
raw changeset »
has_and_belongs_to_many_with_deferred_save/lib/has_and_belongs_to_many_with_deferred_save.rb (3 lines added, 0 lines removed)
Up to file-list has_and_belongs_to_many_with_deferred_save/lib/has_and_belongs_to_many_with_deferred_save.rb:
| … | … | @@ -21,6 +21,9 @@ module ActiveRecord |
21 |
21 |
has_and_belongs_to_many *args |
22 |
22 |
collection_name = args[0].to_s |
23 |
23 |
collection_singular_ids = collection_name.singularize + "_ids" |
24 |
||
25 |
# this will delete all the assocation into the join table after obj.destroy |
|
26 |
after_destroy { |record| record.save } |
|
24 |
27 |
|
25 |
28 |
attr_accessor :"unsaved_#{collection_name}" |
26 |
29 |
attr_accessor :"use_original_collection_reader_behavior_for_#{collection_name}" |
