Google Groups Home
Help | Sign in
update on a m:n table
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  2 messages - Collapse all
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
Christoph Thommen  
View profile
 More options May 10, 2:54 pm
From: Christoph Thommen <rails-mailing-l...@andreas-s.net>
Date: Sat, 10 May 2008 20:54:38 +0200
Local: Sat, May 10 2008 2:54 pm
Subject: 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')
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
--
Posted via http://www.ruby-forum.com/.


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Rails Terrorist  
View profile
 More options May 10, 3:45 pm
From: Rails Terrorist <rails-mailing-l...@andreas-s.net>
Date: Sat, 10 May 2008 21:45:02 +0200
Local: Sat, May 10 2008 3:45 pm
Subject: Re: update on a m:n table
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
--
Posted via http://www.ruby-forum.com/.


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2008 Google