# Update on a m:n table

**URL:** <https://www.ruby-forum.com/t/update-on-a-m-n-table/137257>\
**Category:** Rails\
**Created:** [May 10, 2008, 8:54pm UTC](https://www.ruby-forum.com/t/update-on-a-m-n-table/137257 "2008-05-10T20:54:38Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![sigma](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/dec6dc/32.png) [@sigma](https://www.ruby-forum.com/u/sigma)\
**Post date:** [May 10, 2008, 8:54pm UTC](https://www.ruby-forum.com/t/update-on-a-m-n-table/137257/1 "2008-05-10T20:54:38Z")

</div>

Hi all

following situation:  
3 tables:  
users (id, nickname,…)  
conversations(id, …)  
conversations\_users(user\_id, conversation\_id, date\_deleted)

2: models  
user (has\_and\_belongs\_to\_many :conversations,  
:join\_table=\>‘conversations\_users’, :conditions=\>‘date\_deleted IS NULL’)  
conversation

How can i update update the “date\_deleted” in the m:n join table? If i  
want to do it by  
user.conditions.date\_deleted = DateTime.now

it don’t work

Any idea?

Greets

---

<div class="post-metadata">

**Author:** ![sigma](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/dec6dc/32.png) [@sigma](https://www.ruby-forum.com/u/sigma)\
**Post date:** [May 10, 2008, 9:45pm UTC](https://www.ruby-forum.com/t/update-on-a-m-n-table/137257/2 "2008-05-10T21:45:02Z")

</div>

I dont like this way, but this is my answer :

for sample in user.conditions  
sample.date\_deleted = DateTime.now  
end

but it will hurt your AR or database because it will connect to database  
for each looping. Maybe another have lovely solution.

Reinhart  
[http://teapoci.blogspot.com](http://teapoci.blogspot.com)
