I have a rails form that works well when creating a new model but is buggy when it comes to editing an existing one.
This is the behavior:
When on the
editview, the submit button will not work.If I hit reload, once the
editview has rendered again, the button works fine, and I am able to submit any changes to the database.
Below is the code.
Form:
<%= form_for @client do |f| %> # Don't Think the problem is inside the form since it works after the reload. ... # Here is the button <button type="submit" value="submit" class="btn btn-success btn-lg pull-right cms-button"> <i class="fa fa-check" aria-hidden="true"></i> Update Client </button> <% end %> Controller:
def edit @client = Client.find( params[:id] ) end def update @client = Client.find( params[:id] ) if @client.update( client_params ) flash[:notice] = "Client added succesfully" redirect_to( :action => 'show' ) else render( 'edit)' ) end end Where do I have to make changes so that the update is successful?