On 3 July 2012 15:56, Yusuke Enomoto
<mosaafi-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:> Hello.I have a question. I am making chat application to practice RoR.
>
> I have three models. User, Chat, and Message.
> The relationship is that User has many chats(it means chat''s host)
and many
> message,s Chat has many messages.
>
> Now I want to create a lobby page like this.
> http://freezing-sword-4391.herokuapp.com/chat/lobby
>
> This page shows all chats sorted by the last message''s created_at.
each chat
> shows who is chat''s host, and what the last message is.
>
> Is there any good way to get resource by ActiveRecord''s method?
Sorry, I don''t understand the question.
Have you worked right through some tutorials (railstutorial is good
and is free to use online) to understand the basics of rails? If not
then I suggest you do this.
>
> Besides, the amount of messages will be huge,so is there good way to get
all
> chats which have the last message by loading LIMIT 1 message?
You can fetch just the first record of a query by using .first
Colin
--
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en-US.