jeudi 20 août 2015

Inserting form data into SQLite table using Rails

I have created the table 'kids' which will store names as strings and numbers as integers. Inserting the values manually using an SQL query in the terminal works fine.

I am new to Rails and cannot seem to find any simple examples that show how to grab data from an html form and insert it into my SQLite table.

Here is the form I am dealing with:

<form>
    Kid #1 Name:<input type="text"><br>
    Favorite Number:<input type="text"><br>

    Kid #2 Name:<input type="text"><br>
    Favorite Number:<input type="text"><br>

    <input type="submit" value="Submit">
</form>

What would the Controllers, Models, and Views look like in order to insert data from the form? It is 2 inserts into the table, but 1 form.

Aucun commentaire:

Enregistrer un commentaire