Skip to content
bridgeutopia edited this page Aug 5, 2012 · 6 revisions

Textile Editor Helper Example App

rails new something -d mysql
rake db:create RAILS_ENV=development
rails g scaffold Post body:text 
rake db:migrate 

Example layout

<!DOCTYPE html>
<html>
<head>
  <title>Test Textile Editor Helper</title>
  <%= stylesheet_link_tag    "application", :media => "all" %>
  
  <%= csrf_meta_tags %>
  <%= yield :head %>
</head>
<body>

<%= yield %>
<%= javascript_include_tag "application" %>
<%= yield :javascript %>
</body>
</html>

Example form

<%= form_for(@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="field">
    <%= f.label :body %><br />
    <%= f.textile_editor :body %>
  </div>
  <div class="actions">
    <%= f.submit %>
    <% content_for :javascript do %>
      <%= textile_editor_initialize %>
    <% end %>
  </div>
<% end %>
Clone this wiki locally