ordre présentation forum

This commit is contained in:
Nicolas Bally 2014-06-22 18:20:48 +02:00
parent 4f651eae72
commit fbc8f77120
4 changed files with 7 additions and 4 deletions

View File

@ -5,7 +5,7 @@ class Forum::ForumTopicsController < ApplicationController
def index
@forum_topics = ForumTopic.order("created_at DESC").all
@forum_topics = ForumTopic.all
end
def show

View File

@ -16,6 +16,9 @@ class ForumTopic < ActiveRecord::Base
belongs_to :category, :class_name => "ForumCategory"
default_scope :include => :forum_messages, :order => "forum_messages.created_at DESC"
def username
if self.forum_user
self.forum_user.firstname.to_s+" "+

View File

@ -11,10 +11,10 @@
%td{:style => "width:160px;"}
-if forum_topic.forum_messages.count > 1
=forum_topic.forum_messages.last.username
=forum_topic.forum_messages.order("created_at ASC").last.username
%br
il y a
=distance_of_time_in_words Time.now, forum_topic.forum_messages.last.created_at
=distance_of_time_in_words Time.now, forum_topic.forum_messages.order("created_at ASC").last.created_at
-if moderator?
%td

View File

@ -4,7 +4,7 @@
%h1= @topic.title
%br
%br
=render @topic.forum_messages
=render @topic.forum_messages.order("created_at ASC")
=link_to "ajouter un message", new_forum_forum_message_path(:topic_id => @topic.id), :class => "btn btn-primary", :style => "margin:1em 0em;float:right"