Skip to content

Instantly share code, notes, and snippets.

@cantonic
Created July 27, 2015 06:49
Show Gist options
  • Save cantonic/2535fff39c28af496503 to your computer and use it in GitHub Desktop.
Save cantonic/2535fff39c28af496503 to your computer and use it in GitHub Desktop.
class Drive::BaseController < ApplicationController
#...
def update
authorize! :update, object
if object_strong_params[:name] # indicates that the desired action is to rename the object
desired_action = 'rename'
object_plain_params[:name] = case controller_name
when 'files' then object_strong_params[:name] + '.' + object.name.split('.').last
else object_strong_params[:name]
end
else
desired_action = 'move'
end
object.update!(object_strong_params)
render_js_template("drive/update_#{desired_action}")
end
# ...
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment