Class: Monologue::PostsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/monologue/posts_controller.rb

Instance Method Summary collapse

Methods inherited from ApplicationController

#all_tags, #archive_posts, #not_found, #recent_posts

Instance Method Details

#feedObject



18
19
20
21
22
23
24
25
# File 'app/controllers/monologue/posts_controller.rb', line 18

def feed
  @posts = Monologue::Post.published.limit(25)
  if params[:tags].present?
    tags = Monologue::Tag.where(name: params[:tags].split(",")).pluck(:id)
    @posts = @posts.joins(:taggings).where("monologue_taggings.tag_id in (?)", tags)
  end
  render 'feed', layout: false
end

#indexObject



2
3
4
5
# File 'app/controllers/monologue/posts_controller.rb', line 2

def index
  @page = params[:page].nil? ? 1 : params[:page]
  @posts = Monologue::Post.page(@page).includes(:user).published
end

#showObject



7
8
9
10
11
12
13
14
15
16
# File 'app/controllers/monologue/posts_controller.rb', line 7

def show
  if monologue_current_user
    @post = Monologue::Post.default.where("url = :url", {url: params[:post_url]}).first
  else
    @post = Monologue::Post.published.where("url = :url", {url: params[:post_url]}).first
  end
  if @post.nil?
    not_found
  end
end