I’m building a private message system for one of my sites. I’m now
trying to give users the delete messages in their inbox (not destroy
the records but put “archived = true” in them), so they don’t come up
anymore. This is important because the sender needs to have the
message in his sent items.
Everything is set up but when I do the database query, it simply
returns no messages.
This was my query before the archive feature and shows records: @messages = Message.find_all_by_to(current_user.id, :order =>
“created_at DESC”)
And this is the query with archive feature and shows no records: @messages = Message.find_all_by_to(current_user.id, :conditions =>
{:archived, :order => “created_at DESC”)
The strange thing is that Mongrel shows the right query:
Message Load (0.6ms) SELECT * FROM “messages” WHERE
(“messages”.“archived” = ‘false’) AND (“messages”.“to” = 3) ORDER BY
created_at DESC
But I don’t see any messages anymore (archived and not archived).
The strange thing is that Mongrel shows the right query:
Message Load (0.6ms) SELECT * FROM “messages” WHERE
(“messages”.“archived” = ‘false’) AND (“messages”.“to” = 3) ORDER BY
created_at DESC
But I don’t see any messages anymore (archived and not archived).
What does the database return if you execute the select outside of your
app? (I’m assuming you either know the command-line syntax or have a
GUI front-end.)
15|Hoi Pepi!|7|3|true|2009-07-13 06:40:30|2009-07-13 07:35:35|f
sqlite> SELECT * FROM “messages” WHERE (“messages”.“archived” =
‘false’) AND (“messages”.“to” = 3) ORDER BY created_at DESC;
sqlite>
Suggestions for a better query? Is it an SQLite/MySQL difference?
Never used SQLite before.
If I’m reading the results above correctly, it looks like the ‘archived’
field is the one at the end. Yes? If so, then the query needs to test
for ‘f’ not ‘false’. If not, this it looks like the archived field must
be the one just before the first date and you show no records with a
value of ‘false’.
HTH,
Bill
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.