How to open a form inside a modal with Rails 4 and Foundation?

0

I have a product registration in Rails. I am using Zurb-Foundation 5 as lib in Front End. How do I call an include form within a modal window in the Foundation. I created a partial with the form and tried to insert it inside the div to be called at the moment of the click but it does not work. Trying to be more specific to facilitate. I have the URL:

localhost:3000/products 

The index action should already list all available products and at the same time show the include button. When clicking the button, you should open the modal with the damn inclusion form. I would like to do CRUD operations without changing the URL to / new, / product /: id, and so on. What could I do?

    
asked by anonymous 16.05.2014 / 18:13

1 answer

1

I do not know Zurb-Foundation, but try the following:

Configure the controller's new action to not render any layout:

def new
  [...]
  render :new, layout: :none
end

This will make Rails only send partial HTML, without the entire template ( <html><head>...</head><body>...</body></html> ).

As I said, I do not know the Zend-Foundation, but I think it should work if you can get the HTML and paste it into the modal.

Another way would be to create the form via Javascript itself and make the post request for the "create" action (or other action you want). But for this you will have to deactivate the authentication token for that action ( see the documentation ). / p>     

16.05.2014 / 20:48