# Live preview in rails 2.0

**URL:** <https://www.ruby-forum.com/t/live-preview-in-rails-2-0/127680>\
**Category:** Rails\
**Created:** [January 31, 2008, 11:17am UTC](https://www.ruby-forum.com/t/live-preview-in-rails-2-0/127680 "2008-01-31T11:17:05Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![gorter9](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/839c29/32.png) [@gorter9](https://www.ruby-forum.com/u/gorter9)\
**Post date:** [January 31, 2008, 11:17am UTC](https://www.ruby-forum.com/t/live-preview-in-rails-2-0/127680/1 "2008-01-31T11:17:05Z")

</div>

I’am trying to set a live preview for my rails app  
I using recipe 3 from rails recipies.  
It’s a recipe from rails 1.0 in 2.0 i get no live preview

in my testapp i have the following code

:controller

def new  
@Post = Post.new  
end

def preview  
render :layout =\> false  
end

:model  
class Post \< ActiveRecord::Base  
attr\_accessor :title, :body  
end

view new.rhtml

 \<%= javascript\_include\_tag "prototype"%\> 

\<% form\_for :post, @post, :url=\> {:action =\> ‘create’, :id =\>  
“entry-form” } do |f| %\>

\<%= f.text\_field :title %\>

\<%= f.text\_area :body %\>  
\<%= submit\_tag “Post” %\>  
\<% end %\>

\<%= observe\_form “post-form”,  
:update =\> “live\_preview”,  
:complete =\> “Element.show(‘live-preview’)”,  
:url =\> { :action =\> “preview” }  
%\>

:preview.rhtml

\<%= textilize params[:page][:body]%\>

I got no preview i got nothing.  
The only difference in my code and the book i have is into the new.rhtml  
because start\_form\_tag  
does not longer exists in 2.0

---

<div class="post-metadata">

**Author:** ![gorter9](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/839c29/32.png) [@gorter9](https://www.ruby-forum.com/u/gorter9)\
**Post date:** [February 1, 2008, 12:34pm UTC](https://www.ruby-forum.com/t/live-preview-in-rails-2-0/127680/2 "2008-02-01T12:34:03Z")

</div>

I searched and searched but there is happening nothing.  
Maybe recipe 3 of the book rails recipies is wrong or something.  
How can i use observe\_form?

---

<div class="post-metadata">

**Author:** ![gorter9](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/839c29/32.png) [@gorter9](https://www.ruby-forum.com/u/gorter9)\
**Post date:** [February 1, 2008, 1:38pm UTC](https://www.ruby-forum.com/t/live-preview-in-rails-2-0/127680/3 "2008-02-01T13:38:15Z")

</div>

For now the log gets all the new information from the preview.  
But i got nothing on screen only a black line

This is into my log

Processing HomeController#preview (for 127.0.0.1 at 2008-02-01 13:38:28)  
[POST]  
Session ID:  
BAh7BzoMY3NyZl9pZCIlZDQ0ZGRlMmEwOTIwMzA2OTA3M2UyYTQ2ZWQ0NTU3%0ANTUiCmZsYXNoSUM6J0FjdGlvbkNvbnRyb2xsZXI6OkZsYXNoOjpGbGFzaEhh%0Ac2h7AAY6CkB1c2VkewA%3D–f5e9513b61438c135c515f4e91ff56f0596d1691  
Parameters: {“commit”=\>“Post”, “post”=\>{“title”=\>“”,  
“body”=\>“fdfdffddf”},  
“authenticity\_token”=\>“90dfa19958c89b163d86e29bebe88b1bf56fc90a”,  
“action”=\>“preview”, “controller”=\>“home”}  
Rendering home/preview  
Post Columns (0.003355) SHOW FIELDS FROM `posts`  
Completed in 0.01117 (89 reqs/sec) | Rendering: 0.00172 (15%) | DB:  
0.00336 (30%) | 200 OK [[http://0.0.0.0/home/preview](http://0.0.0.0/home/preview)]

In my view i have this

\<%= observe\_form “post-form”,  
:frequency =\> 1,  
:update =\> “live\_preview”,  
:complete =\> “Element.show(‘live-preview’)”,  
:url =\> { :action =\> “preview” }  
%\>

but the div gives no result of the preview method
