hi,i have a table called blogs which include t.column :user_id, :integer t.column :post_id, :integer t.column:title, :string t.column:body, :string and i have a seperate form to fill the title and post field,i can display the title and body in a page.but the records are displayed in the ascending order,that means the last i last i entered is displayed first ..but i want to display it in descending order,,,that mean the newly entered record should display at the top of the page,,,please can anyone send me the code to do this --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
> the last i last i entered is displayed first > ..but i want to display it in descending order,,,that mean the newly entered > record should display at the top of the pageIsn''t that the same? Last/newly entered display first? anyway, in the examples replace DESC by ASC to revert order if your model has a created_at column: @blogs = Blog.find(:all, :order => "created_at DESC") if you don''t have the created_at col (you should), sort by id: @blogs = Blog.find(:all, :order => "id DESC") --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
thankx....il try 2008/11/4 Thorsten Müller <thorsten-1oxKqHKwyltBDgjK7y7TUQ@public.gmane.org>> > > the last i last i entered is displayed first > > ..but i want to display it in descending order,,,that mean the newly > entered > > record should display at the top of the page > > Isn''t that the same? Last/newly entered display first? > > anyway, in the examples replace DESC by ASC to revert order > > if your model has a created_at column: > @blogs = Blog.find(:all, :order => "created_at DESC") > > if you don''t have the created_at col (you should), sort by id: > @blogs = Blog.find(:all, :order => "id DESC") > > > >--~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---