diff options
Diffstat (limited to 'app/controllers/assets_controller.rb')
| -rw-r--r-- | app/controllers/assets_controller.rb | 16 |
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 |
