I have an edit page that comes with devise. To use it in my app i need to render a special layout and that layout should be rendered only in edit page. So inorder to override i wrote edit method.. here is my registration_controller.rb
def edit
session[:tab] = "Edit Profile"
render layout: 'calculator'
end
def update
self.resource = resource_class.to_adapter.get!(send(:"current_#{resource_name}").to_key)
prev_unconfirmed_email = resource.unconfirmed_email if resource.respond_to?(:unconfirmed_email)
p '----------------'
resource_updated = update_resource(resource, account_update_params)
yield resource if block_given?
if resource_updated
if is_flashing_format?
flash_key = update_needs_confirmation?(resource, prev_unconfirmed_email) ?
:update_needs_confirmation : :updated
set_flash_message :notice, flash_key
end
sign_in resource_name, resource, bypass: true
respond_with resource, location: after_update_path_for(resource)
else
clean_up_passwords resource
redirect to '/users/edit'
end
end
Thing is if I enter wrong password an error occurs and the rendering fails. So i thought of redirecting to edit url in my update function. Thing is i want to show the error messages too when it redirects to edit page.
Or is there any easy way to do this. I want to render a layout in edit page which wont break when an error occurs while updating(like password mismatch)