summaryrefslogtreecommitdiff
path: root/app/controllers/assets_controller.rb
diff options
context:
space:
mode:
authorerdgeist <erdgeist@erdgeist.org>2026-06-26 01:59:57 +0200
committererdgeist <erdgeist@erdgeist.org>2026-06-26 01:59:57 +0200
commitc06723ee715512c2033c7786c48f15674585b56b (patch)
tree46d074bde9a4fc61f0a76cbc601007ed4412ec61 /app/controllers/assets_controller.rb
parent0818a3057b0a91e422158d828026c941b4e10622 (diff)
Stage 4: Rails 5.2 -> 6.1 on Ruby 2.7.2
- routing-filter 0.6.3 -> 0.7.0 (Rails 6.1 compatibility) - RSS named routes rss_xml/rss_rdf added - RouteWithParams workarounds: will_paginate_patch, content_path shim, safe_path helper - Paperclip removed, replaced with FileAttachment concern (preserves URL scheme) - Assets resource moved to /admin/assets (Sprockets middleware conflict) - ApplicationRecord base class added, all models migrated - Strong parameters added to Assets, Occurrences, Events, MenuItems controllers - update_attributes -> update throughout - render :nothing -> head :ok/:not_found throughout - language_selector rewritten (removes :overwrite_params) - Environment files updated for Rails 6.1 (eager_load, public_file_server, ActionMailer) - Arel::Visitors::DepthFirst and Integer/Float duration patches removed from test_helper - AssetsController tests added (10 tests covering upload, variants, destroy, auth) - ImageMagick geometry: 460x250! for headline crop (not # which is invalid in IM6) 129 runs, 311 assertions, 5 failures (all pre-existing), 0 errors
Diffstat (limited to 'app/controllers/assets_controller.rb')
-rw-r--r--app/controllers/assets_controller.rb17
1 files changed, 11 insertions, 6 deletions
diff --git a/app/controllers/assets_controller.rb b/app/controllers/assets_controller.rb
index a11bbdd..d150e06 100644
--- a/app/controllers/assets_controller.rb
+++ b/app/controllers/assets_controller.rb
@@ -7,10 +7,9 @@ class AssetsController < ApplicationController
7 layout 'admin' 7 layout 'admin'
8 8
9 def index 9 def index
10 @assets = Asset.all.paginate( 10 @assets = Asset.order('id DESC').paginate(
11 :page => params[:page], 11 :page => params[:page],
12 :per_page => 20, 12 :per_page => 20
13 :order => 'id DESC'
14 ) 13 )
15 end 14 end
16 15
@@ -44,7 +43,7 @@ class AssetsController < ApplicationController
44 # POST /assets 43 # POST /assets
45 # POST /assets.xml 44 # POST /assets.xml
46 def create 45 def create
47 @asset = Asset.new(params[:asset]) 46 @asset = Asset.new(asset_params)
48 47
49 respond_to do |format| 48 respond_to do |format|
50 if @asset.save 49 if @asset.save
@@ -64,7 +63,7 @@ class AssetsController < ApplicationController
64 @asset = Asset.find(params[:id]) 63 @asset = Asset.find(params[:id])
65 64
66 respond_to do |format| 65 respond_to do |format|
67 if @asset.update_attributes(params[:asset]) 66 if @asset.update(asset_params)
68 flash[:notice] = 'Asset was successfully updated.' 67 flash[:notice] = 'Asset was successfully updated.'
69 format.html { redirect_to(@asset) } 68 format.html { redirect_to(@asset) }
70 format.xml { head :ok } 69 format.xml { head :ok }
@@ -86,4 +85,10 @@ class AssetsController < ApplicationController
86 format.xml { head :ok } 85 format.xml { head :ok }
87 end 86 end
88 end 87 end
88
89 private
90
91 def asset_params
92 params.require(:asset).permit(:name, :upload)
93 end
89end 94end