Commit da802e73

mo k <mo@mokhan.ca>
2012-09-11 01:58:57
tidy up the new tutorial form.
1 parent 0844c47
Changed files (3)
app/views/tutorials/_form.html.erb
@@ -1,29 +1,26 @@
-<%= form_for(@tutorial) do |f| %>
-  <% if @tutorial.errors.any? %>
-    <div id="error_explanation">
-      <h2><%= pluralize(@tutorial.errors.count, "error") %> prohibited this tutorial from being saved:</h2>
-
-      <ul>
-      <% @tutorial.errors.full_messages.each do |msg| %>
-        <li><%= msg %></li>
-      <% end %>
-      </ul>
+<%= form_for(@tutorial, :html => {:class => "form-horizontal"}) do |f| %>
+  <fieldset>
+    <div class="control-group">
+      <%= f.label :heading, :class => "control-label" %>
+      <div class="controls">
+        <%= f.text_field :heading, :class => "input-xlarge" %>
+      </div>
     </div>
-  <% end %>
-
-  <div class="field">
-    <%= f.label :heading %><br />
-    <%= f.text_field :heading %>
-  </div>
-  <div class="field">
-    <%= f.label :description %><br />
-    <%= f.text_area :description %>
-  </div>
-  <div class="field">
-    <%= f.label :url %><br />
-    <%= f.text_field :url %>
-  </div>
-  <div class="actions">
-    <%= f.submit %>
-  </div>
+    <div class="control-group">
+      <%= f.label :url, :class => "control-label" %>
+      <div class="controls">
+        <%= f.text_field :url, :class => "input-xlarge" %>
+      </div>
+    </div>
+    <div class="control-group">
+      <%= f.label :description, :class => "control-label" %>
+      <div class="controls">
+        <%= f.text_area :description, :class => "input-xlarge" %>
+      </div>
+    </div>
+    <div class="form-actions">
+      <button type="submit" class="btn btn-primary">Save changes</button>
+      <a href="<%= url_for tutorials_url %>" class="btn">Cancel</a>
+    </div>
+  </fieldset>
 <% end %>
app/views/tutorials/new.html.erb
@@ -1,5 +1,9 @@
-<h1>New tutorial</h1>
-
-<%= render 'form' %>
-
-<%= link_to 'Back', tutorials_path %>
+<% provide(:title, "Share a tutorial") -%>
+<div class="page-header">
+  <h1>Share a new tutorial</h1>
+</div>
+<div class="row">
+  <div class="span12">
+    <%= render 'form' %>
+  </div>
+</div>
spec/requests/tutorials_spec.rb
@@ -3,7 +3,6 @@ require 'spec_helper'
 describe "Tutorials" do
   describe "GET /tutorials" do
     it "works! (now write some real specs)" do
-      # Run the generator again with the --webrat flag if you want to use webrat methods/matchers
       get tutorials_path
       response.status.should be(200)
     end