Auto maintain the consistency of redundant column.
Add this line to your application's Gemfile:
gem 'redundant_column'
And then execute:
$ bundle
Or install it yourself as:
$ gem install redundant_column
class User < ActiveRecord::Base
has_many :topics, :redundant_column => {:status => :user_status}
end
class Topic < ActiveRecord::Base
belongs_to :user, :redundant_column => {:user_status => :status}
end
user = User.create(:name => "Hooopo", :status => "active")
topic = Topic.create(:user => user, :title => "this is title")
assert_equal topic.user_status, user.status
user.status = "disable"
user.save
topic.reload
assert_equal topic.user_status, user.status
git checkout -b my-new-feature
)git commit -am 'Added some feature'
)git push origin my-new-feature
)