Update on a m:n table

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’)

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?


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

for sample in user.conditions
sample.date_deleted = DateTime.now

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


This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs