11class SourcesController < ApplicationController
2- before_action :set_source , except : [ : index, : new, : create, : check_exists]
3- before_action :set_content_provider , except : [ : index, : check_exists]
2+ before_action :set_source , except : %i[ index new create check_exists ]
3+ before_action :set_content_provider , except : %i[ index check_exists ]
44 before_action :set_breadcrumbs
55
66 include SearchableIndex
@@ -65,8 +65,8 @@ def check_exists
6565 end
6666 else
6767 respond_to do |format |
68- format . html { render : nothing => true , : status => 200 , : content_type => 'text/html' }
69- format . json { render json : { } , : status => 200 , : content_type => 'application/json' }
68+ format . html { render nothing : true , status : 200 , content_type : 'text/html' }
69+ format . json { render json : { } , status : 200 , content_type : 'application/json' }
7070 end
7171 end
7272 end
@@ -75,6 +75,7 @@ def check_exists
7575 # PATCH/PUT /sources/1.json
7676 def update
7777 authorize @source
78+
7879 respond_to do |format |
7980 if @source . update ( source_params )
8081 @source . create_activity ( :update , owner : current_user ) if @source . log_update_activity?
@@ -94,8 +95,10 @@ def destroy
9495 @source . create_activity :destroy , owner : current_user
9596 @source . destroy
9697 respond_to do |format |
97- format . html { redirect_to policy ( Source ) . index? ? sources_path : content_provider_path ( @content_provider ) ,
98- notice : 'Source was successfully deleted.' }
98+ format . html do
99+ redirect_to policy ( Source ) . index? ? sources_path : content_provider_path ( @content_provider ) ,
100+ notice : 'Source was successfully deleted.'
101+ end
99102 format . json { head :no_content }
100103 end
101104 end
@@ -106,7 +109,7 @@ def test
106109 @source . test_job_id = job_id
107110
108111 respond_to do |format |
109- format . json { render json : { id : job_id } }
112+ format . json { render json : { id : job_id } }
110113 end
111114 end
112115
@@ -150,11 +153,11 @@ def set_content_provider
150153
151154 # Never trust parameters from the scary internet, only allow the white list through.
152155 def source_params
153- permitted = [ : url, : method, : token, : default_language, : enabled]
156+ permitted = %i[ url method token default_language enabled source_filters ]
154157 permitted << :approval_status if policy ( @source || Source ) . approve?
155158 permitted << :content_provider_id if policy ( Source ) . index?
156159
157- params . require ( :source ) . permit ( permitted )
160+ params . require ( :source ) . permit ( permitted , source_filters_attributes : %i[ id mode property value _destroy ] )
158161 end
159162
160163 def set_breadcrumbs
@@ -164,7 +167,7 @@ def set_breadcrumbs
164167 add_breadcrumb 'Sources' , content_provider_path ( @content_provider , anchor : 'sources' )
165168
166169 if params [ :id ]
167- add_breadcrumb @source . title , content_provider_source_path ( @content_provider , @source ) if ( @source && !@source . new_record? )
170+ add_breadcrumb @source . title , content_provider_source_path ( @content_provider , @source ) if @source && !@source . new_record?
168171 add_breadcrumb action_name . capitalize . humanize , request . path unless action_name == 'show'
169172 elsif action_name != 'index'
170173 add_breadcrumb action_name . capitalize . humanize , request . path
@@ -173,5 +176,4 @@ def set_breadcrumbs
173176 super
174177 end
175178 end
176-
177179end
0 commit comments