Class: Publinator::PublishableController

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

Instance Method Summary collapse

Methods inherited from ApplicationController

#body_id, #current_controller, #current_domain, #current_layout, #current_site, #current_site_name

Instance Method Details

#indexObject



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'app/controllers/publinator/publishable_controller.rb', line 5

def index
  @publication = Publinator::Publication.find_by_publishable_type_and_slug(params[:publishable_type].classify, 'index')
  @publishable_type = Publinator::PublishableType.find_by_name(params[:publishable_type].classify)
  if @publication
    @publishable = @publication.publishable
    begin
      render "#{params[:publishable_type]}/show"
    rescue ActionView::MissingTemplate
      render "publinator/publishable/show"
    end
  else
    @publishables = params[:publishable_type].classify.constantize.all
    begin
      render "#{params[:publishable_type]}/index"
    rescue ActionView::MissingTemplate
      render "publinator/publishable/index"
    end
  end
end

#showObject



25
26
27
28
29
30
31
32
33
34
# File 'app/controllers/publinator/publishable_controller.rb', line 25

def show
  @publication = Publinator::Publication.find_by_publishable_type_and_slug(params[:publishable_type].classify, params[:id])
  @publishable = @publication.publishable
  @publishable_type = Publinator::PublishableType.find_by_name(params[:publishable_type].classify)
  begin
    render "#{params[:publishable_type]}/show"
  rescue ActionView::MissingTemplate
    render "publinator/publishable/show"
  end
end