File tree Expand file tree Collapse file tree
app/controllers/active_storage_db
spec/dummy/app/controllers Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -17,12 +17,12 @@ def show
1717 def update
1818 if ( token = decode_verified_token )
1919 file_uploaded = upload_file ( token )
20- head ( file_uploaded ? :no_content : unprocessable )
20+ head ( file_uploaded ? :no_content : ActiveStorageDB :: UNPROCESSABLE_STATUS )
2121 else
2222 head ( :not_found )
2323 end
2424 rescue ActiveStorage ::IntegrityError
25- head ( unprocessable )
25+ head ( ActiveStorageDB :: UNPROCESSABLE_STATUS )
2626 end
2727
2828 private
@@ -60,13 +60,5 @@ def upload_file(token) # rubocop:disable Naming/PredicateMethod
6060 db_service . upload ( token [ :key ] , request . body , checksum : token [ :checksum ] )
6161 true
6262 end
63-
64- def unprocessable
65- if Rails ::VERSION ::MAJOR > 7 || ( Rails ::VERSION ::MAJOR == 7 && Rails ::VERSION ::MINOR >= 1 )
66- :unprocessable_content
67- else
68- :unprocessable_entity
69- end
70- end
7163 end
7264end
Original file line number Diff line number Diff line change 11# frozen_string_literal: true
22
33module ActiveStorageDB
4+ # :nocov:
5+ UNPROCESSABLE_STATUS = if Rails ::VERSION ::MAJOR > 7 || ( Rails ::VERSION ::MAJOR == 7 && Rails ::VERSION ::MINOR >= 1 )
6+ :unprocessable_content
7+ else
8+ :unprocessable_entity
9+ end
10+ # :nocov:
11+
412 class Engine < ::Rails ::Engine
513 isolate_namespace ActiveStorageDB
614 end
Original file line number Diff line number Diff line change @@ -32,7 +32,7 @@ def create
3232 format . json { render :show , status : :created , location : @post }
3333 else
3434 format . html { render :new }
35- format . json { render json : { errors : @post . errors } , status : unprocessable }
35+ format . json { render json : { errors : @post . errors } , status : ActiveStorageDB :: UNPROCESSABLE_STATUS }
3636 end
3737 end
3838 end
@@ -46,7 +46,7 @@ def update
4646 format . json { render :show , status : :ok , location : @post }
4747 else
4848 format . html { render :edit }
49- format . json { render json : { errors : @post . errors } , status : unprocessable }
49+ format . json { render json : { errors : @post . errors } , status : ActiveStorageDB :: UNPROCESSABLE_STATUS }
5050 end
5151 end
5252 end
@@ -70,8 +70,4 @@ def load_post
7070 def post_params
7171 params . fetch ( :post ) { { } } . permit!
7272 end
73-
74- def unprocessable
75- Rails ::VERSION ::MAJOR > 7 || ( Rails ::VERSION ::MAJOR == 7 && Rails ::VERSION ::MINOR >= 1 ) ? :unprocessable_content : :unprocessable_entity
76- end
7773end
You can’t perform that action at this time.
0 commit comments