ruby-rcade/RubyGameDev.com

View on GitHub
app/views/posts/_form.html.erb

Summary

Maintainability
Test Coverage
<%= form_for(@post, url: (@post.new_record? ? posts_path : post_path(@post)), as: :internal_post) do |f| %>
  <% if @post.errors.any? %>
    <div id="error_explanation">
      <h2>
        <%= pluralize(@post.errors.count, "error") %>
        prohibited this post from being saved:
      </h2>

      <ul>
      <% @post.errors.full_messages.each do |msg| %>
        <li><%= msg %></li>
      <% end %>
      </ul>
    </div>
  <% end %>

  <div class="form-group">
    <%= f.label :title, "Title" %>
    <%= f.text_field :title, class: 'form-control input-lg' %>
  </div>

  <div class="form-group">
    <%= f.label :body_markdown, "Body markdown" %>
    <%= f.text_area :body_markdown, class: 'form-control', rows: 5 %>
  </div>

  <div class="form-group tags-form">
    <%= f.label :tags_string, "Tags" %>
    <%= f.text_field :tags_string, class: 'form-control tags-input', autocomplete: 'off' %>
  </div>

  <%= f.submit nil, class: 'btn btn-default' %>
<% end %>