显示用户的帖子

时间:2012-05-18 03:21:27

标签: ruby-on-rails ruby

我有act_as_follower宝石。其中:

class Section < ActiveRecord::Base
  has_many :posts
  acts_as_followable
  # ...
end

class User < ActiveRecord::Base
  acts_as_follower
  has_one :section
  has_many :posts
  # ...
end

SectionController:

def follow
  @section = Section.find(params[:id])
  @section.user = current_user

  if @section.user == nil
    # We don't follow this yet
    @section.user.follow(@section)
    msg = "You are suscribed to this Section"
  elsif @section.user.following?(@section)
    # We already follow this
    @section.user.stop_following(@section)
    msg = "You are't suscribed to this Section anymore"
  else
    # We don't follow this yet
    @section.user.follow(@section)
    msg = "You are suscribed to this Section"
  end
  redirect_to section_path(@section), :notice => msg
end

这一切工作正常,但我想在created_at descarticles.index的顺序显示所遵循的部分的文章。

0 个答案:

没有答案