summaryrefslogtreecommitdiff
path: root/app/controllers/assets_controller.rb
diff options
context:
space:
mode:
authorerdgeist <erdgeist@erdgeist.org>2026-08-09 13:26:23 +0200
committererdgeist <erdgeist@erdgeist.org>2026-08-09 13:26:23 +0200
commit616a0d2d2ba15a7e176938ee829d60366fb6a9c2 (patch)
treefe12e0ab804948f0e3ff37636859b05cef7871cc /app/controllers/assets_controller.rb
parent42b996e9197680a1955cfa5639462908677e5a94 (diff)
Attach an asset to a page from the asset's own page
The picker moves from assets/edit to assets/show, where the list of attached pages already is. A member route, POST assets/:id/attach_to_node, replaces the ride on #update. Supersedes the picker wiring in the previous commit; what remains of it is @attach_node in #create, the flash composition and the corrected hint.
Diffstat (limited to 'app/controllers/assets_controller.rb')
-rw-r--r--app/controllers/assets_controller.rb16
1 files changed, 14 insertions, 2 deletions
diff --git a/app/controllers/assets_controller.rb b/app/controllers/assets_controller.rb
index e58f4f30..4b27d1c4 100644
--- a/app/controllers/assets_controller.rb
+++ b/app/controllers/assets_controller.rb
@@ -38,7 +38,6 @@ class AssetsController < ApplicationController
38 # GET /assets/1/edit 38 # GET /assets/1/edit
39 def edit 39 def edit
40 @asset = Asset.find(params[:id]) 40 @asset = Asset.find(params[:id])
41 @attach_node = Node.not_in_trash.find_by(:id => params[:node_id]) if params[:node_id].present?
42 end 41 end
43 42
44 # POST /assets 43 # POST /assets
@@ -69,7 +68,6 @@ class AssetsController < ApplicationController
69 # PUT /assets/1.xml 68 # PUT /assets/1.xml
70 def update 69 def update
71 @asset = Asset.find(params[:id]) 70 @asset = Asset.find(params[:id])
72 @attach_node = Node.not_in_trash.find_by(:id => params[:node_id]) if params[:node_id].present?
73 71
74 respond_to do |format| 72 respond_to do |format|
75 if @asset.update(asset_params) 73 if @asset.update(asset_params)
@@ -102,6 +100,20 @@ class AssetsController < ApplicationController
102 end 100 end
103 end 101 end
104 102
103 # POST /assets/1/attach_to_node
104 def attach_to_node
105 @asset = Asset.find(params[:id])
106 node = Node.not_in_trash.find_by(:id => params[:node_id])
107
108 if node
109 attach_to(node)
110 else
111 flash[:error] = t("flash.assets.attach_no_node")
112 end
113
114 redirect_to(asset_path(@asset))
115 end
116
105 private 117 private
106 118
107 def asset_params 119 def asset_params