Question

I brought in a static website into a brand new RoR app. I dropped the entire directory into the public folder so I wouldn't have to change the application layout. I now want to capture data from one of the static pages forms...I have the following code in the static page but it's not correctly saving to the database.

#public/test/index.html
<form action="resellers#create" method="post">
<label>
    <input id="number" type="text" placeholder="Enter number"/>
</label>
<label>
    <input id="type" type="text" name="email" placeholder="Email"/>
</label>
</form>
Was it helpful?

Solution

resellers#create isn't an actual form action that you can submit to in a browser. That's just the way Rails refers to it in its routes. What you'll need to do is run rake routes, or if you're using RoR 4+, visit /rails/info/routes in development mode to see what route resellers#create is actually pointing to, probably POST /resellers.

However, unless you specifically set it in your configuration, you can't submit to the form because Rails is smart and wants a secure token for each form submission to prevent forgeries and other nasty things. You're much better off having your static website point to the form and just making a route to the form look like it's part of your static website.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top