Class: ArticlesController

Inherits:
BaseController show all
Defined in:
app/controllers/articles_controller.rb

Instance Attribute Summary

Attributes inherited from BaseController

#section, #site

Instance Method Summary collapse

Methods included from Adva::AuthenticateUser

#authenticate_user, #authenticated?, #current_user, included

Methods included from ResourceHelper

#current_controller_namespace, #links_to_actions, #normalize_resource_link_options, #normalize_resource_link_text, #normalize_resource_type, #resource_delete_options, #resource_link, #resource_link_id, #resource_owners, #resource_url, #resource_url_method, #resource_url_namespace

Methods included from ContentHelper

#content_category_checkbox, #content_path, #content_status, #link_to_category, #link_to_content, #link_to_preview, #link_to_tag, #links_to_content_categories, #links_to_content_tags, #page_link_path, #published_at_formatted

Instance Method Details

#indexObject



2
3
4
5
6
7
8
9
# File 'app/controllers/articles_controller.rb', line 2

def index
  @article = articles.first
  if !@article
    raise ActiveRecord::RecordNotFound
  else
    show
  end
end

#showObject



11
12
13
14
15
16
17
18
19
20
21
# File 'app/controllers/articles_controller.rb', line 11

def show
  @article ||= section.articles.find_by_permalink!(params[:permalink])
  if @article.draft?
    raise ActiveRecord::RecordNotFound unless current_user.admin?
  end
  return redirect_to @article.body if @article.is_a?(Link)

  if stale?([*@article.cells, @article, section, site], public: true)
    render template: "#{section.type.tableize}/articles/show"
  end
end