How to use Ruby on Rails 5 + Ajax + jQuery to render a New Form on the Index View

Video is ready, Click Here to View ×

I’m learning to code in Ruby on Rails 5 with Ajax and a bit of jQuery. I had a hard time figuring out how to show the new item form on the index using Ajax, so that it doesn’t refresh the page or navigate to the new page view.

I got it working and thought I’d share how to do it.

In this video, you’ll see me modify link_to tag using remote: true, Ajax, and a bit of jQuery.

Upon clicking the link, it will instantly render the form partial on the index page, without refreshing or going to another page.

I hope this helped!

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.