No release in over 3 years
Low commit activity in last 3 years
Destroy associations if specified attribute is blank
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
 Dependencies

Development

~> 1.5
>= 0
>= 0

Runtime

 Project Readme

DestroyAssociates

Destroy association if specified attribute is blank.

Build Status

Installation

Add this line to your application's Gemfile:

gem 'destroy_associates'

And then execute:

$ bundle

Or install it yourself as:

$ gem install destroy_associates

Usage

Add "destroy_associates_if_blank" to model.

class User < ActiveRecord::Base
  has_many :mails
  accepts_nested_attributes_for :mails

  destroy_associates_if_blank :mails, :address
end

class Mail < ActiveRecord::Base
  belongs_to :user
  attr_accessible :address
end
user.mails
=> [<Mail id: 1, user_id: 1, address: "alice@example.inc">]

user.mails.first.address = ""
user.save!

user.mails
=> []

License

This gem is released under the MIT license.

Contributing

  1. Fork it ( http://github.com/h-izumi/destroy_associates/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')