11class ResourcesController < ApplicationController
2-
32 def index
43 if turbo_frame_request?
54 per_page = params [ :number_of_items_per_page ] . presence || 25
@@ -17,7 +16,7 @@ def index
1716 "#{ filtered_count } /#{ total_count } "
1817 end
1918
20- render :search_results
19+ render :resource_results
2120 else
2221 render :index
2322 end
@@ -65,11 +64,11 @@ def update
6564 @resource = Resource . find ( params [ :id ] )
6665 @resource . user ||= current_user
6766 if @resource . update ( resource_params )
68- flash [ :notice ] = ' Resource updated.'
67+ flash [ :notice ] = " Resource updated."
6968 redirect_to resources_path
7069 else
7170 set_form_variables
72- flash [ :alert ] = ' Failed to update Resource.'
71+ flash [ :alert ] = " Failed to update Resource."
7372 render :edit
7473 end
7574 end
@@ -80,32 +79,31 @@ def destroy
8079 redirect_to resources_path , notice : "Resource was successfully destroyed."
8180 end
8281
83-
8482 def search
8583 process_search
8684 @sortable_fields = Resource ::PUBLISHED_KINDS
8785 render :index
8886 end
8987
9088 def download
91- if params [ :attachment_id ] . to_i > 0
92- attachment = Attachment . where ( owner_type : "Resource" , id : params [ :attachment_id ] ) . last
89+ attachment = if params [ :attachment_id ] . to_i > 0
90+ Attachment . where ( owner_type : "Resource" , id : params [ :attachment_id ] ) . last
9391 else
94- attachment = Resource . find ( params [ :resource_id ] ) . download_attachment
92+ Resource . find ( params [ :resource_id ] ) . download_attachment
9593 end
9694
9795 if attachment &.file &.blob . present?
9896 redirect_to rails_blob_url ( attachment . file , disposition : "attachment" )
9997 else
10098 if params [ :from ] == "resources_index"
10199 path = resources_path
102- elsif params [ :from ] == "dashboard_index"
103- path = authenticated_root_path
104- else
105- resource_path ( params [ :resource_id ] )
106- end
100+ elsif params [ :from ] == "dashboard_index"
101+ path = authenticated_root_path
102+ else
103+ resource_path ( params [ :resource_id ] )
104+ end
107105 redirect_to path ,
108- alert : "File not found or not attached."
106+ alert : "File not found or not attached."
109107 end
110108 end
111109
@@ -117,8 +115,8 @@ def set_form_variables
117115
118116 @windows_types = WindowsType . all
119117 @authors = User . active . or ( User . where ( id : @resource . user_id ) )
120- . order ( :first_name , :last_name )
121- . map { |u | [ u . full_name , u . id ] }
118+ . order ( :first_name , :last_name )
119+ . map { |u | [ u . full_name , u . id ] }
122120 end
123121
124122 def process_search
0 commit comments