Created
July 27, 2015 06:49
-
-
Save cantonic/2535fff39c28af496503 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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