Render a form from a modal while on the index page?

398 views Asked by At

I have a modal that works fine once the "new movie" button is clicked (to add a movie to the collection. I want to enable ajax and take advantage of Rails UJS, so I want the form to pop up as a modal and let the user add it without having to leave "movies#index." I can get the modal to pop up fine, but once I put <%render 'form'%> in the modal the index page won't reload. It won't allow me to put an empty object on the page. How do people take advantage of Rails built in UJS and ajax helpers, I don't understand.

calling the new action in movies controller

Everything works fine as I would expect when i put a modal on the page, use remote: true, and test the "new movie button." However, once I put the form in the modal, in my case by using a partial, everything starts to break.

note: all i'm doing is refreshing to get this error

All i do is refresh the page and I get this error. I played around with it for two hours I cannot figure out what the proper way is to use ajax and UJS in Rails. Any help is GREATLY appreciated.

0

There are 0 answers