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 def index
@forum_topics = ForumTopic.order("created_at DESC").all @forum_topics = ForumTopic.all
end end
def show def show

View File

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

View File

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

View File

@ -4,7 +4,7 @@
%h1= @topic.title %h1= @topic.title
%br %br
%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" =link_to "ajouter un message", new_forum_forum_message_path(:topic_id => @topic.id), :class => "btn btn-primary", :style => "margin:1em 0em;float:right"