Class: Tasks::CollectionObjects::BrowseController

Inherits:
ApplicationController
  • Object
show all
Includes:
PinboardItemsHelper, TaskControllerConfiguration
Defined in:
app/controllers/tasks/collection_objects/browse_controller.rb

Instance Method Summary collapse

Methods included from PinboardItemsHelper

#get_pinboard_item_from_object, #insert_pinboard_item_link, #inserted_pinboard_item_object_for_klass, #next_object_by_inserted_keyword, #next_previous_by_inserted_keyword, #pin_item_to_pinboard_link, #pinboard_item_li_tag, #pinboard_item_options, #previous_object_by_inserted_keyword

Methods included from TaskControllerConfiguration

#set_is_task_controller

Instance Method Details

#indexObject

GET



6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'app/controllers/tasks/collection_objects/browse_controller.rb', line 6

def index
  scope = CollectionObject.where(project_id: sessions_current_project_id)

  if params[:collection_object_id]
    @collection_object = scope.find(params[:collection_object_id])
  elsif pinned = inserted_pinboard_item_object_for_klass('CollectionObject')
    redirect_to browse_collection_objects_task_path(collection_object_id: pinned.id) and return
  elsif random = scope.offset(rand(scope.count)).first
    redirect_to browse_collection_objects_task_path(collection_object_id: random.id) and return
  else
    redirect_to new_collection_object_path, notice: 'Create a collection object first.' and return
  end
end