Class: Spotlight::PagesController

Inherits:
ApplicationController show all
Includes:
Blacklight::Base, Blacklight::Catalog::SearchContext
Defined in:
app/controllers/spotlight/pages_controller.rb

Instance Method Summary collapse

Methods inherited from ApplicationController

#search_action_url

Instance Method Details

#createObject

POST /exhibits/1/pages



36
37
38
39
40
41
42
43
44
45
# File 'app/controllers/spotlight/pages_controller.rb', line 36

def create
  @page.attributes = page_params
  @page.last_edited_by = @page.created_by = current_user

  if @page.save
    redirect_to [@page.exhibit, page_collection_name], notice: 'Page was successfully created.'
  else
    render action: 'new'
  end
end

#destroyObject

DELETE /pages/1



57
58
59
60
# File 'app/controllers/spotlight/pages_controller.rb', line 57

def destroy
  @page.destroy
  redirect_to [@page.exhibit, @page], notice: 'Page was successfully destroyed.'
end

#editObject

GET /pages/1/edit



32
33
# File 'app/controllers/spotlight/pages_controller.rb', line 32

def edit
end

#indexObject

GET /exhibits/1/pages



18
19
20
21
# File 'app/controllers/spotlight/pages_controller.rb', line 18

def index
  # set up a model the inline "add a new page" form
  @page = CanCan::ControllerResource.new(self).send(:build_resource)
end

#newObject

GET /exhibits/1/pages/new



28
29
# File 'app/controllers/spotlight/pages_controller.rb', line 28

def new
end

#showObject

GET /pages/1



24
25
# File 'app/controllers/spotlight/pages_controller.rb', line 24

def show
end

#updateObject

PATCH/PUT /pages/1



48
49
50
51
52
53
54
# File 'app/controllers/spotlight/pages_controller.rb', line 48

def update
  if @page.update(page_params.merge(last_edited_by: current_user))
    redirect_to [@page.exhibit, page_collection_name], notice: 'Page was successfully updated.'
  else
    render action: 'edit'
  end
end

#update_allObject



62
63
64
65
66
67
68
69
# File 'app/controllers/spotlight/pages_controller.rb', line 62

def update_all
  notice = if @exhibit.update update_all_page_params
    "#{human_name} were successfully updated."
  else
    "There was an error updating the requested pages."
  end
  redirect_to :back, notice: notice
end