What is the easiest way to implement soft-deletes on has_many through association?
What I want is something like this:
class Company > ActiveRecord::Base
has_many :staffings
has_many :users, through: :staffings, conditions: {staffings: {active: true}}
end
I want to use Company#users the following way:
Company#users should be a normal association so that it works with forms.Staffing with active: true is created.Staffing is updated active: false (currently it just get deleted).Staffing#active == false) the Staffing is updated to active: true.I thought about overriding the Company#users= method, but it really isn't good enough since there are other ways of updating the associations.
What is the Rails Way of doing this sort of thing?
--
You received this message because you are subscribed to the Google Groups "Ruby or Rails Oceania" group.
To post to this group, send email to rails-...@googlegroups.com.
To unsubscribe from this group, send email to rails-oceani...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rails-oceania?hl=en.
Not quite sure how that would fit into an association setup, though. I'm sure it'd be possible to code something together.
--
Pat
--
You received this message because you are subscribed to the Google Groups "Ruby or Rails Oceania" group.
To post to this group, send email to rails-...@googlegroups.com.
To unsubscribe from this group, send email to rails-oceani...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rails-oceania?hl=en.
You might need to use before_create to check that the row doesn't already exist (in a deactivated state).