1

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 edit view, the submit button will not work.

  • If I hit reload, once the edit view 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?

3
  • does this question help: stackoverflow.com/questions/19365809/… Commented May 26, 2016 at 20:16
  • Not exactly, but it helped motivated me to revert some HTML changes and test. The issue got fixed by doing this. If you post the answer I will mark it as accepted. Commented May 26, 2016 at 20:26
  • What changes did you revert in html? Would be useful for future users Commented May 27, 2016 at 4:27

1 Answer 1

3

It might be an issue with the HTML that is unrelated to rails itself, this question has the same problem: Form Submit button only works after reload

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.