diff options
| author | erdgeist <erdgeist@erdgeist.org> | 2026-06-26 01:59:57 +0200 |
|---|---|---|
| committer | erdgeist <erdgeist@erdgeist.org> | 2026-06-26 01:59:57 +0200 |
| commit | c06723ee715512c2033c7786c48f15674585b56b (patch) | |
| tree | 46d074bde9a4fc61f0a76cbc601007ed4412ec61 /app/controllers | |
| parent | 0818a3057b0a91e422158d828026c941b4e10622 (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')
| -rw-r--r-- | app/controllers/assets_controller.rb | 17 | ||||
| -rw-r--r-- | app/controllers/content_controller.rb | 9 | ||||
| -rw-r--r-- | app/controllers/events_controller.rb | 10 | ||||
| -rw-r--r-- | app/controllers/menu_items_controller.rb | 15 | ||||
| -rw-r--r-- | app/controllers/nodes_controller.rb | 6 | ||||
| -rw-r--r-- | app/controllers/occurrences_controller.rb | 11 | ||||
| -rw-r--r-- | app/controllers/pages_controller.rb | 2 | ||||
| -rw-r--r-- | app/controllers/users_controller.rb | 2 |
8 files changed, 48 insertions, 24 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 | ||
| 89 | end | 94 | end |
diff --git a/app/controllers/content_controller.rb b/app/controllers/content_controller.rb index 876bccf..8d33105 100644 --- a/app/controllers/content_controller.rb +++ b/app/controllers/content_controller.rb | |||
| @@ -15,13 +15,14 @@ class ContentController < ApplicationController | |||
| 15 | 15 | ||
| 16 | if @page and @page.public? | 16 | if @page and @page.public? |
| 17 | render( | 17 | render( |
| 18 | :file => @page.valid_template, | 18 | :template => @page.valid_template, |
| 19 | :layout => true | 19 | :layout => true |
| 20 | ) | 20 | ) |
| 21 | else | 21 | else |
| 22 | render( | 22 | render( |
| 23 | :file => Rails.root.join('public', '404.html'), | 23 | :file => Rails.root.join('public', '404.html').to_s, |
| 24 | :status => 404 | 24 | :status => 404, |
| 25 | :layout => false | ||
| 25 | ) | 26 | ) |
| 26 | end | 27 | end |
| 27 | 28 | ||
| @@ -32,7 +33,7 @@ class ContentController < ApplicationController | |||
| 32 | @images = @page.assets.images | 33 | @images = @page.assets.images |
| 33 | render :file => "content/gallery" | 34 | render :file => "content/gallery" |
| 34 | else | 35 | else |
| 35 | render :nothing => true, :status => 404 | 36 | head :not_found |
| 36 | end | 37 | end |
| 37 | end | 38 | end |
| 38 | 39 | ||
diff --git a/app/controllers/events_controller.rb b/app/controllers/events_controller.rb index 6eba476..7695e9b 100644 --- a/app/controllers/events_controller.rb +++ b/app/controllers/events_controller.rb | |||
| @@ -47,7 +47,7 @@ class EventsController < ApplicationController | |||
| 47 | # POST /events | 47 | # POST /events |
| 48 | # POST /events.xml | 48 | # POST /events.xml |
| 49 | def create | 49 | def create |
| 50 | @event = Event.new(params[:event]) | 50 | @event = Event.new(event_params) |
| 51 | 51 | ||
| 52 | respond_to do |format| | 52 | respond_to do |format| |
| 53 | if @event.save | 53 | if @event.save |
| @@ -67,7 +67,7 @@ class EventsController < ApplicationController | |||
| 67 | @event = Event.find(params[:id]) | 67 | @event = Event.find(params[:id]) |
| 68 | 68 | ||
| 69 | respond_to do |format| | 69 | respond_to do |format| |
| 70 | if @event.update_attributes(params[:event]) | 70 | if @event.update(event_params) |
| 71 | flash[:notice] = 'Event was successfully updated.' | 71 | flash[:notice] = 'Event was successfully updated.' |
| 72 | format.html { redirect_to(edit_node_path(@event.node)) } | 72 | format.html { redirect_to(edit_node_path(@event.node)) } |
| 73 | format.xml { head :ok } | 73 | format.xml { head :ok } |
| @@ -89,4 +89,10 @@ class EventsController < ApplicationController | |||
| 89 | format.xml { head :ok } | 89 | format.xml { head :ok } |
| 90 | end | 90 | end |
| 91 | end | 91 | end |
| 92 | |||
| 93 | private | ||
| 94 | |||
| 95 | def event_params | ||
| 96 | params.require(:event).permit(:start_time, :end_time, :rrule, :custom_rrule, :allday, :url, :latitude, :longitude, :node_id, :location) | ||
| 97 | end | ||
| 92 | end | 98 | end |
diff --git a/app/controllers/menu_items_controller.rb b/app/controllers/menu_items_controller.rb index 4018693..1b1eb59 100644 --- a/app/controllers/menu_items_controller.rb +++ b/app/controllers/menu_items_controller.rb | |||
| @@ -14,11 +14,11 @@ class MenuItemsController < ApplicationController | |||
| 14 | end | 14 | end |
| 15 | 15 | ||
| 16 | def new | 16 | def new |
| 17 | @menu_item = MenuItem.new params[:menu_item] | 17 | @menu_item = MenuItem.new menu_item_params |
| 18 | end | 18 | end |
| 19 | 19 | ||
| 20 | def create | 20 | def create |
| 21 | if MenuItem.create( params[:menu_item] ) | 21 | if MenuItem.create( menu_item_params ) |
| 22 | redirect_to menu_items_path | 22 | redirect_to menu_items_path |
| 23 | else | 23 | else |
| 24 | render :new | 24 | render :new |
| @@ -32,7 +32,7 @@ class MenuItemsController < ApplicationController | |||
| 32 | def update | 32 | def update |
| 33 | @menu_item = MenuItem.find( params[:id] ) | 33 | @menu_item = MenuItem.find( params[:id] ) |
| 34 | 34 | ||
| 35 | if @menu_item.update_attributes( params[:menu_item] ) | 35 | if @menu_item.update( menu_item_params ) |
| 36 | redirect_to menu_items_path | 36 | redirect_to menu_items_path |
| 37 | else | 37 | else |
| 38 | render :edit | 38 | render :edit |
| @@ -48,10 +48,15 @@ class MenuItemsController < ApplicationController | |||
| 48 | def sort | 48 | def sort |
| 49 | params[:menu_items].each_with_index do |item_id, index| | 49 | params[:menu_items].each_with_index do |item_id, index| |
| 50 | menu_item = MenuItem.find(item_id) | 50 | menu_item = MenuItem.find(item_id) |
| 51 | menu_item.update_attributes(:position => index + 1) | 51 | menu_item.update(:position => index + 1) |
| 52 | end | 52 | end |
| 53 | 53 | ||
| 54 | render :nothing => true | 54 | head :ok |
| 55 | end | 55 | end |
| 56 | 56 | ||
| 57 | private | ||
| 58 | |||
| 59 | def menu_item_params | ||
| 60 | params.require(:menu_item).permit(:node_id, :path, :position, :type, :type_id) | ||
| 61 | end | ||
| 57 | end | 62 | end |
diff --git a/app/controllers/nodes_controller.rb b/app/controllers/nodes_controller.rb index 482d0ac..bd60b27 100644 --- a/app/controllers/nodes_controller.rb +++ b/app/controllers/nodes_controller.rb | |||
| @@ -36,7 +36,7 @@ class NodesController < ApplicationController | |||
| 36 | @node.slug = params[:title].parameterize.to_s | 36 | @node.slug = params[:title].parameterize.to_s |
| 37 | 37 | ||
| 38 | if @node.save | 38 | if @node.save |
| 39 | @node.draft.update_attributes(:title => params[:title]) | 39 | @node.draft.update(:title => params[:title]) |
| 40 | case params[:kind] | 40 | case params[:kind] |
| 41 | when "update" | 41 | when "update" |
| 42 | @node.draft.tag_list.add("update") | 42 | @node.draft.tag_list.add("update") |
| @@ -70,10 +70,10 @@ class NodesController < ApplicationController | |||
| 70 | end | 70 | end |
| 71 | 71 | ||
| 72 | def update | 72 | def update |
| 73 | @node.update_attributes(node_params) | 73 | @node.update(node_params) |
| 74 | @draft = @node.find_or_create_draft current_user | 74 | @draft = @node.find_or_create_draft current_user |
| 75 | @draft.tag_list = params[:tag_list] | 75 | @draft.tag_list = params[:tag_list] |
| 76 | if @draft.update_attributes( page_params ) | 76 | if @draft.update( page_params ) |
| 77 | flash[:notice] = "Draft has been saved: #{Time.now}" | 77 | flash[:notice] = "Draft has been saved: #{Time.now}" |
| 78 | respond_to do |format| | 78 | respond_to do |format| |
| 79 | format.html { redirect_to edit_node_path(@node) } | 79 | format.html { redirect_to edit_node_path(@node) } |
diff --git a/app/controllers/occurrences_controller.rb b/app/controllers/occurrences_controller.rb index 61b42ff..0f30ce3 100644 --- a/app/controllers/occurrences_controller.rb +++ b/app/controllers/occurrences_controller.rb | |||
| @@ -45,7 +45,7 @@ class OccurrencesController < ApplicationController | |||
| 45 | # POST /occurrences | 45 | # POST /occurrences |
| 46 | # POST /occurrences.xml | 46 | # POST /occurrences.xml |
| 47 | def create | 47 | def create |
| 48 | @occurrence = Occurrence.new(params[:occurrence]) | 48 | @occurrence = Occurrence.new(occurrence_params) |
| 49 | 49 | ||
| 50 | respond_to do |format| | 50 | respond_to do |format| |
| 51 | if @occurrence.save | 51 | if @occurrence.save |
| @@ -65,7 +65,7 @@ class OccurrencesController < ApplicationController | |||
| 65 | @occurrence = Occurrence.find(params[:id]) | 65 | @occurrence = Occurrence.find(params[:id]) |
| 66 | 66 | ||
| 67 | respond_to do |format| | 67 | respond_to do |format| |
| 68 | if @occurrence.update_attributes(params[:occurrence]) | 68 | if @occurrence.update(occurrence_params) |
| 69 | flash[:notice] = 'Occurrence was successfully updated.' | 69 | flash[:notice] = 'Occurrence was successfully updated.' |
| 70 | format.html { redirect_to(@occurrence) } | 70 | format.html { redirect_to(@occurrence) } |
| 71 | format.xml { head :ok } | 71 | format.xml { head :ok } |
| @@ -87,4 +87,11 @@ class OccurrencesController < ApplicationController | |||
| 87 | format.xml { head :ok } | 87 | format.xml { head :ok } |
| 88 | end | 88 | end |
| 89 | end | 89 | end |
| 90 | |||
| 91 | private | ||
| 92 | |||
| 93 | def occurrence_params | ||
| 94 | params.require(:occurrence).permit(:start_time, :end_time, :node_id, :event_id) | ||
| 95 | end | ||
| 96 | |||
| 90 | end | 97 | end |
diff --git a/app/controllers/pages_controller.rb b/app/controllers/pages_controller.rb index f5609eb..a40bf10 100644 --- a/app/controllers/pages_controller.rb +++ b/app/controllers/pages_controller.rb | |||
| @@ -22,6 +22,6 @@ class PagesController < ApplicationController | |||
| 22 | page = Page.find(params[:id]) | 22 | page = Page.find(params[:id]) |
| 23 | page.update_assets(params[:images]) | 23 | page.update_assets(params[:images]) |
| 24 | 24 | ||
| 25 | render :nothing => true, :status => 200 | 25 | head :ok |
| 26 | end | 26 | end |
| 27 | end | 27 | end |
diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 72e6058..98fd534 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb | |||
| @@ -36,7 +36,7 @@ class UsersController < ApplicationController | |||
| 36 | permitted = user_params | 36 | permitted = user_params |
| 37 | permitted.delete(:admin) unless current_user.is_admin? | 37 | permitted.delete(:admin) unless current_user.is_admin? |
| 38 | 38 | ||
| 39 | if @user.update_attributes(permitted) | 39 | if @user.update(permitted) |
| 40 | flash[:notice] = "Updated user #{@user.login}" | 40 | flash[:notice] = "Updated user #{@user.login}" |
| 41 | redirect_to user_path(@user) | 41 | redirect_to user_path(@user) |
| 42 | else | 42 | else |
