Class: PostsController

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

Overview

Copyright © 2010, Diaspora Inc. This file is

  licensed under the Affero General Public License version 3 or later.  See
  the COPYRIGHT file.

Instance Method Summary (collapse)

Methods inherited from ApplicationController

#after_sign_in_path_for, #clear_gc_stats, #ensure_http_referer_is_set, #ensure_page, #grammatical_gender, #redirect_unless_admin, #set_git_header, #set_grammatical_gender, #set_header_data, #set_invites, #set_locale, #which_action_and_user

Instance Method Details

- (Object) show



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'app/controllers/posts_controller.rb', line 10

def show
  @post = Post.where(:id => params[:id], :public => true).includes(:author, :comments => :author).first

  if @post
    @landing_page = true
    @person = @post.author
    if @person.owner_id
      I18n.locale = @person.owner.language
      render "posts/#{@post.class.to_s.underscore}", :layout => true
    else
      flash[:error] = I18n.t('posts.doesnt_exist')
      redirect_to root_url
    end
  else
    flash[:error] = I18n.t('posts.doesnt_exist')
    redirect_to root_url
  end
end