Class: Atrium::ExhibitsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/atrium/exhibits_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

#collectionObject



46
47
48
49
50
# File 'app/controllers/atrium/exhibits_controller.rb', line 46

def collection
  @collection ||= find_collection


end

#createObject



10
11
12
13
14
15
16
17
18
# File 'app/controllers/atrium/exhibits_controller.rb', line 10

def create
  @exhibit = collection.exhibits.build(params[:exhibit])
  if @exhibit.save!
    flash[:notice] = 'Exhibit was successfully created.'
    redirect_to edit_collection_exhibit_path(id:@exhibit.id, collection_id:@collection)
  else
    render action: "new"
  end
end

#destroyObject



35
36
37
38
39
# File 'app/controllers/atrium/exhibits_controller.rb', line 35

def destroy
  @exhibit.destroy
  flash[:notice] = 'Exhibit '+params[:id] +' was deleted successfully.'
  redirect_to edit_collection_path(@collection)
end

#editObject



20
21
22
# File 'app/controllers/atrium/exhibits_controller.rb', line 20

def edit

end

#find_collectionObject



52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'app/controllers/atrium/exhibits_controller.rb', line 52

def find_collection
  begin
    logger.debug("Finding collection")
    if params[:collection_id]
      @collection = Atrium::Collection.find(params[:collection_id])
    elsif params[:id]
      @exhibit = Atrium::Exhibit.find(params[:id])
      @collection = @exhibit.collection
    else
      raise "Could not find collection_id"
    end
  rescue ActiveRecord::RecordNotFound
    flash.alert = t("Atrium.collection.or.exhibit.not_found")
    redirect_to redirect_target and return
  end
  @collection
end

#find_exhibitObject



42
43
44
# File 'app/controllers/atrium/exhibits_controller.rb', line 42

def find_exhibit
  @exhibit = collection.exhibits.find(params[:id])
end

#newObject



6
7
8
# File 'app/controllers/atrium/exhibits_controller.rb', line 6

def new
  @exhibit = collection.exhibits.build(params[:exhibit])
end

#showObject



31
32
33
# File 'app/controllers/atrium/exhibits_controller.rb', line 31

def show
  @showcases = @exhibit.showcases
end

#updateObject



24
25
26
27
28
29
# File 'app/controllers/atrium/exhibits_controller.rb', line 24

def update
  if @exhibit.update_attributes(params[:exhibit])
    flash[:notice] = 'Exhibit was successfully updated.'
  end
  render action: "edit"
end