Blog

edit.erb for Testing Sinatra Ruby Framework CRUD Operations with RSpec and Capybara Gems
Posted on August 10, 2015 in Ruby, Sinatra by Matt Jennings

See this post for a full describe of files used in a Sinatra Ruby framework for CRUD (Create Read Update Delete) operations with RSpec and Capybara testing.

/views/projects/edit.erb

<!doctype>
<html>
<head>
  <title>Edit the <%= @project.name %> Project</title>
  <link rel="stylesheet" type="text/css" href="../../css/styles.css" />
</head>

<body>

<div id="wrapper">

  <h1>Edit the <%= @project.name %> Project</h1>

  <form id="project-form" action="/projects/<%= @project.id %>" method="post">
    <input type="hidden" name="_method" value="patch" />
    <p>
      <label for="name">Name:</label>
      <input type="text" name="name" value="<%= @project.name %>" />
    </p>
    <p>
      <label for="description">Description:</label>
      <input type="text" name="description" value="<%= @project.description %>" />
    </p>
    <p>
      <input type="submit" value="Update Project" />
    </p>
  </form>

  <form action="/projects/<%= @project.id %>" method="post">
    <input type="hidden" name="_method" value="delete" />
    <p>
      <input type="submit" value="Delete Project" />
    </p>
  </form>

  <p>&nbsp;</p>

  <p class="important"><a href="/projects">&raquo; View All Project</a></p>

</div>

</body>
</html>

Leave a Reply

To Top ↑