How to do a block from embedded ruby (rhtml)

I want to drop deprecated code as per:

start_form_tag and end_form_tag
Use form_tag with a block.

However, I’m not sure how to do a block from the rhtml file. Somewhere
I
need curly braces for a block? Or, does it mean an “end” statement?
The
embedded part is throwing me off a bit.

thufir@arrakis ~/strawr $
thufir@arrakis ~/strawr $ cat app/views/feeds/show.rhtml -n | head -n
53
| tail -n 18
36
37 <% @unused_tags =
38 Tag.find(:all) - @feed.tags %>
39
40 <% if @unused_tags.any? %>
41
42 <%= form_tag :action => “add_some_tags”,
43 :id => @feed %>
44 Add a tag:

45 <% @unused_tags.each {|tag| %>
46 <%= check_box(‘tag’+tag.id.to_s, ‘checked’) +
47 tag.tag %>

48 <% } %>
49 <%= submit_tag %>
50 <%= end_form_tag %>
51 <% end %>


52
53
thufir@arrakis ~/strawr $

http://code.google.com/p/strawr/source

thanks,

Thufir

On 23 Jan 2008, at 11:10, Thufir wrote:

statement? The
embedded part is throwing me off a bit.

<% form_tag :action => ‘foo’ do %>
bla bla bla
<% end %>

On Wed, 23 Jan 2008 11:37:17 +0000, Frederick C. wrote:

<% form_tag :action => ‘foo’ do %>
bla bla bla
<% end %>

Following this (and trying to follow the API) results in:

SyntaxError in Feeds#show

Showing app/views/feeds/show.rhtml where line #43 raised:

compile error
/home/thufir/strawr/app/views/feeds/show.rhtml:43: syntax error,
unexpected ‘)’
_erbout.concat " "; _erbout.concat(( form_tag :action =>
“add_some_tags”, :id => @feed.id do ).to_s); _erbout.concat “\n”

^
/home/thufir/strawr/app/views/feeds/show.rhtml:50: syntax error,
unexpected kEND, expecting ‘)’
end ; _erbout.concat “

\n”
^
/home/thufir/strawr/app/views/feeds/show.rhtml:57: syntax error,
unexpected kEND, expecting ‘)’

Extracted source (around line #43):

40: Tag.find(:all) - @feed.tags %>
41:
42: <% if @unused_tags.any? %>
43: <%= form_tag :action => “add_some_tags”, :id => @feed.id do %>
44: Add a tag:

45: <% @unused_tags.each {|tag| %>
46: <%= check_box(‘tag’+tag.id.to_s, ‘checked’) + tag.tag %>

If line 44 is syntactically correct (which I think it is, then perhaps
the source of the error message lies in line 46, converting
tag.id.to_s ,or maybe there’s a missing “end” (but that part looked ok
to
me).

for source code:

http://code.google.com/p/strawr/source
and
http://strawr.googlecode.com/svn/trunk/app/views/feeds/show.rhtml

thanks,

Thufir

On 24 Jan 2008, at 09:01, Thufir wrote:

On Wed, 23 Jan 2008 11:37:17 +0000, Frederick C. wrote:

<% form_tag :action => ‘foo’ do %>
bla bla bla
<% end %>

Following this (and trying to follow the API) results in:

Well you haven’t done that. you’ve used <%=, whereas I used <%

Fred

I stand corrected!

Thanks :slight_smile:

-Thufir