Commit 768008f6 authored by Alfredo Sumaran's avatar Alfredo Sumaran

Respond to json requests

parent 78530162
...@@ -11,15 +11,16 @@ class ProfilesController < Profiles::ApplicationController ...@@ -11,15 +11,16 @@ class ProfilesController < Profiles::ApplicationController
def update def update
user_params.except!(:email) if @user.ldap_user? user_params.except!(:email) if @user.ldap_user?
respond_to do |format|
if @user.update_attributes(user_params) if @user.update_attributes(user_params)
flash[:notice] = "Profile was successfully updated" message = "Profile was successfully updated"
format.html { redirect_back_or_default(default: { action: 'show' }, options: { notice: message }) }
format.json { render json: { message: message } }
else else
messages = @user.errors.full_messages.uniq.join('. ') message = @user.errors.full_messages.uniq.join('. ')
flash[:alert] = "Failed to update profile. #{messages}" format.html { redirect_back_or_default(default: { action: 'show' }, options: { alert: "Failed to update profile. #{message}" }) }
format.json { render json: { message: message }, status: :unprocessable_entity }
end end
respond_to do |format|
format.html { redirect_back_or_default(default: { action: 'show' }) }
end end
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment