Class: Atrium::DescriptionsController

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

Instance Method Summary collapse

Methods inherited from ApplicationController

#atrium_config

Methods included from ShowcasesHelper

#facet_element, #get_parent_path, #get_showcase_parent_edit_path, #get_showcase_parent_show_path, #render_showcase_facet_selection

Methods included from ApplicationHelper

#application_name

Methods included from CollectionsHelper

#get_saved_items, #get_saved_search, #saved_searches_for_select

Instance Method Details

#createObject



15
16
17
18
19
20
21
22
23
# File 'app/controllers/atrium/descriptions_controller.rb', line 15

def create
  @description = showcase.descriptions.build(params[:description])
  if @description.save
    flash[:notice] = 'Description was successfully created.'
    redirect_to edit_showcase_description_path(showcase, @description)
  else
    render action: "new"
  end
end

#destroyObject



40
41
42
43
44
# File 'app/controllers/atrium/descriptions_controller.rb', line 40

def destroy
  description.destroy
  flash[:notice] = 'Description '+@description.pretty_title + ' was deleted successfully.'
  redirect_to edit_showcase_path(@showcase)
end

#editObject



25
26
27
28
# File 'app/controllers/atrium/descriptions_controller.rb', line 25

def edit
  description.build_essay(content_type:"essay") unless description.essay
  description.build_summary(content_type:"summary") unless description.summary
end

#indexObject



5
6
7
# File 'app/controllers/atrium/descriptions_controller.rb', line 5

def index
  @descriptions = showcase.descriptions
end

#newObject



9
10
11
12
13
# File 'app/controllers/atrium/descriptions_controller.rb', line 9

def new
  @description = showcase.descriptions.build(params[:description])
  @description.build_essay(content_type:"essay")
  @description.build_summary(content_type:"summary")
end

#updateObject



30
31
32
33
34
35
36
37
38
# File 'app/controllers/atrium/descriptions_controller.rb', line 30

def update
  if description.update_attributes(params[:description])
    flash[:notice] = 'Description was successfully updated.'
    redirect_to edit_showcase_description_path(showcase, @description)
  else
    flash.now.alert = 'Description update failed'
    render action: "edit"
  end
end