gorter9
January 31, 2008, 11:17am
1
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
gorter9
February 1, 2008, 12:34pm
2
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?
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 ]
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