简体   繁体   中英

How to connect pre-build HTML Form to a database using Ruby?

I know that with ruby you can use the scaffolding command, and it'll make the html form for you. But i already create the HTML Form manually, and i don't know how to connect your existing HTML Form to a database using Ruby. I create the HTML around Bootstrap framework, and place the form within a Modal.

Here is a snippet of my HTML Form:

<div class="modal fade" id="signModal">
  <div class="modal-dialog">
    <div class="modal-content">

      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
        <h6 class="modal-title2">Sign Up Form</h6>
      </div>
      <div class="modal-body">
        <form>
          <div class="form-group">
            <label for="InputEmail">Email</label>
            <input type="email" class="form-control form-control-inline" id="InputEmail" placeholder="Email">
          </div>
          <div class="form-group">
            <label for="InputFirst">First Name</label>
            <input type="text" class="form-control form-control-inline" id="InputFirst" placeholder="First Name">
          </div>
          <div class="form-group">
            <label for="InputLast">Last Name</label>
            <input type="text" class="form-control form-control-inline" id="InputLast" placeholder="Last Name">
          </div>
        </form>
        <label for="mobilePhone">Mobile Phone</label>
        <form class="form-inline">
          <div class="form-group">
            <input type="tel" class="form-control" id="mobilePhone" placeholder="Mobile Phone">
          </div>
          <div class="form-group">
            <select class="form-control">
              <option>Android</option>
              <option>iOS</option>
            </select>
          </div>
        </form>
        <div class="formButton">
          <button type="submit" class="btn btn-primary" data-dismiss="modal">Submit</button>
        </div>
      </div>

    </div>
  </div>
</div> <!-- End Modal -->

I'm still new to Ruby. Hope i explained my question well. Thanks a bunch! :D

You have to use rails form or simple form gem to convert your form. Please check rails guide or simple form documentation for details.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM