Friday, January 22, 2010

Recipe 3: Showing a Live Preview

(This post is one of a series that updates Chad Fowler's Rails Recipes for Rails 2.)

What. The RedCloth gem is used to preview formatted text the user enters.

Anachronism. The only anachronism in this recipe concerns the change in how forms are typically built. In place of the form code in the text, something like the following is needed:

<% form_for @entry,  
:url => {:action => "save"},
:html => { :id => "entry-form"} do |f| %>
<br/><%= f.text_field :title %><br />
<br/><%= f.text_area :body, :rows => 3 %><br />
<%= submit_tag "Save" %>
<% end %>

No comments:

Post a Comment