Forum: Ruby on Rails Problem in following Ruby 'Blog' Screencast

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Aae4a8b022fa6f1142c14461496808bf?d=identicon&s=25 Michael (Guest)
on 2009-01-09 16:55
(Received via mailing list)
Hi all,

When attempting to follow the screencast, 'Creating a weblog in 15
minutes with Rails 2', I've hit a problem when creating the
'partial'.  As soon as the index.html.erb,

<h1>Listing posts</h1>

<%= render :partial => @posts %>

<%= link_to 'New post', new_post_path %>

with _post.html.erb.

<% div for post do %>
  <h2><%= link_to_unless_current h(post.title), post %></h2>
  <%= simple_format h(post.body) %>
<% end %>

and show.html.erb,

<%= render :partial => @post %>

<p>
  <%= link_to 'Edit', edit_post_path(@post) %> |
  <%= link_to 'Destroy', @post, :method => :delete, :confirm => "Are
you sure?" %>
  <%= link_to 'See All Posts', posts_path %>
</p>

I'm getting the following error:

 SyntaxError in Posts#index

Showing app/views/posts/_post.html.erb where line #1 raised:

compile error
/Users/michael/Desktop/rails_demo/blog/app/views/posts/_post.html.erb:
1: syntax error, unexpected kDO_BLOCK, expecting tCOLON2 or '[' or '.'
            old_output_buffer = output_buffer;post = local_assigns
[:post];object = local_assigns[:object];post_counter = local_assigns
[:post_counter];;@output_buffer = '';  __in_erb_template=true ;  div
for post do ; @output_buffer.concat "\n"

^
/Users/michael/Desktop/rails_demo/blog/app/views/posts/_post.html.erb:
5: syntax error, unexpected kENSURE, expecting $end

Extracted source (around line #1):

1: <% div for post do %>
2:   <h2><%= link_to_unless_current h(post.title), post %></h2>
3:   <%= simple_format h(post.body) %>
4: <% end %>

Trace of template inclusion: app/views/posts/_post.html.erb, app/views/
posts/index.html.erb

Any ideas?

ruby --version
ruby 1.8.6 (2008-03-03 patchlevel 114) [universal-darwin9.0]

Cheers
Mike
247cd3d37084a3d6794076207bd9fbd7?d=identicon&s=25 Bobnation (Guest)
on 2009-01-09 17:20
(Received via mailing list)
Take the "div" out of there ... that looks odd there.

Just looking over it, that looks like the problem (maybe). However, I
haven't watched the new screencast ... so I can't really tell you.
8fa0f5c2bf8ad238baa4e20cb0360ebd?d=identicon&s=25 Matt Harrison (iwasinnamuknow)
on 2009-01-09 17:22
(Received via mailing list)
Bobnation wrote:
> Take the "div" out of there ... that looks odd there.

Certainly does.

> Just looking over it, that looks like the problem (maybe). However, I
> haven't watched the new screencast ... so I can't really tell you.

Also shouldn't it be

for post in @posts do
   ...
end

Unless there's some ruby cleverness I've missed.

HTH

Matt
This topic is locked and can not be replied to.