fixed post stream to ascend by time
This commit is contained in:
parent
c63eac0fd9
commit
da9f33aa72
6 changed files with 25 additions and 17 deletions
|
|
@ -2,13 +2,6 @@ class DashboardController < ApplicationController
|
|||
before_filter :authenticate_user!
|
||||
|
||||
def index
|
||||
@posts = Post.all
|
||||
|
||||
@bookmarks = Bookmark.all
|
||||
@status_messages = StatusMessage.all
|
||||
@blogs = Blog.all
|
||||
#@status_messages = @posts.select{ |x| x._type == "StatusMessage"}
|
||||
#@blogs = @posts.select{ |x| x._type == "Blog"}
|
||||
#@bookmarks = @posts.select{ |x| x._type == "Bookmarks"}
|
||||
@posts = Post.recent_ordered_posts
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -14,10 +14,24 @@ class Post
|
|||
field :source
|
||||
field :snippet
|
||||
|
||||
|
||||
before_create :set_defaults
|
||||
#after_update :notify_friends
|
||||
|
||||
|
||||
|
||||
@@models = ["StatusMessage", "Bookmark", "Blog"]
|
||||
|
||||
def self.recent_ordered_posts
|
||||
# Need to explicitly name each inherited model for dev environment
|
||||
query = if Rails.env == "development"
|
||||
Post.criteria.all(:_type => @@models)
|
||||
else
|
||||
Post.criteria.all
|
||||
end
|
||||
query.order_by( [:created_at, :desc] )
|
||||
end
|
||||
|
||||
|
||||
protected
|
||||
|
||||
def set_defaults
|
||||
|
|
@ -33,7 +47,5 @@ class Post
|
|||
#xml = self.to_xml_to_s
|
||||
#friends.each{|friend| ping friend :with => xml }
|
||||
#end
|
||||
|
||||
end
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,9 @@
|
|||
- title "Dashboard"
|
||||
|
||||
|
||||
%ul#stream
|
||||
- for post in @posts
|
||||
%li
|
||||
= render "shared/post", :post =>post
|
||||
/= post.inspect
|
||||
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ Diaspora::Application.configure do
|
|||
# test suite. You never need to work with it otherwise. Remember that
|
||||
# your test database is "scratch space" for the test suite and is wiped
|
||||
# and recreated between test runs. Don't rely on the data there!
|
||||
config.cache_classes = false
|
||||
config.cache_classes = true
|
||||
|
||||
# Log error messages when you accidentally call methods on nil.
|
||||
config.whiny_nils = true
|
||||
|
|
|
|||
|
|
@ -19,8 +19,8 @@ test:
|
|||
# set these environment variables on your prod server
|
||||
production:
|
||||
<<: *defaults
|
||||
host: <%= ENV['MONGOID_HOST'] %>
|
||||
port: <%= ENV['MONGOID_PORT'] %>
|
||||
username: <%= ENV['MONGOID_USERNAME'] %>
|
||||
password: <%= ENV['MONGOID_PASSWORD'] %>
|
||||
database: <%= ENV['MONGOID_DATABASE'] %>
|
||||
#host: <%= ENV['MONGOID_HOST'] %>
|
||||
#port: <%= ENV['MONGOID_PORT'] %>
|
||||
#username: <%= ENV['MONGOID_USERNAME'] %>
|
||||
#password: <%= ENV['MONGOID_PASSWORD'] %>
|
||||
#database: <%= ENV['MONGOID_DATABASE'] %>
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ Rspec.configure do |config|
|
|||
config.before(:each) do
|
||||
Mongoid.master.collections.select { |c| c.name != 'system.indexes' }.each(&:drop)
|
||||
|
||||
|
||||
end
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue