Problem in following Ruby 'Blog' Screencast

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,

Listing posts

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

<%= link_to ‘New post’, new_post_path %>

with _post.html.erb.

<% div for post do %>

<%= link_to_unless_current h(post.title), post %>

<%= simple_format h(post.body) %> <% end %>

and show.html.erb,

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

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

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:

<%= link_to_unless_current h(post.title), post %>


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

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.

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 forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs