Created
April 14, 2014 00:27
-
-
Save luckyruby/10607996 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
def update | |
respond_to do |format| | |
format.js { | |
if request.xhr? | |
@user = User.find(params[:id]) | |
params[:user][:location_ids] ||= [] | |
@user.assign_attributes(safe_params) | |
if @user.save | |
@users = users_list | |
render template: 'users/list' | |
else | |
render template: 'users/form' | |
end | |
end | |
} | |
end | |
end | |
private | |
def safe_params | |
params.require(:user).permit(:username, :first_name, :last_name, :active, location_ids: []) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment