Wiki create page fails with useless error

Beats me where to send this…but somebody should fix it. I gave up
and removed the dead link & added a pointer to the semi-useful RSS
feed…that at least created correctly.

I was trying to update a wiki page, and the create simply said that
the create validation failed with value ‘false’
Here’s the wiki page…
http://wiki.rubyonrails.org/rails/pages/HowtoWorkWithHelpers

And the edit which I inserted inbetween the ‘see also’ and the
‘category’:
From the now dead link (apologies to Bruce for the raw copy):
http://codefluency.com/2006/5/28/rails-views-helpers-that-take-blocks
(found at http://www.planetrubyonrails.org/show/feed/164)

Rails Views: Block Helper Example

Posted by Bruce 644 days ago

A few articles back, I mentioned how useful helpers that take blocks
can be within your views.

I thought I’d give a little example, giving a helper I find pretty
useful in my own projects.

Here’s the code, which I’ll explain in a moment:


def link_to_section(name, html_opts={}, &block)
  section_id = name.underscore.gsub(/\s+/,'_')
  link_id = section_id + '_link'
  # Link
  concat(link_to_function(name,update_page{|page|
    page[section_id].show
    page[link_id].hide
  }, html_opts.update(:id=>link_id)), block.binding)
  # Hidden section
  concat(tag('div',
{:id=>section_id, :style=>'display:none;'},true),block.binding)
  yield update_page{|page|
    page[section_id].hide
    page[link_id].show
  }
  concat('', block.binding) end

What this makes possible is stuff like:


<% link_to_section("View Details") do |closer| %>

Details

Some detailed text detailing detailed details.


<%= link_to_function("Hide Details",closer) %>
<% end %>

What’s going on here is actually pretty simple. The helper generates a
link (with the label you’ve given) to show a a hidden div and hide
itself. The block given to the helper is what will end up inside that
div, and it’s yielded the snippet of javascript necessary to switch
back (so that you can use that snippet wherever you’d like).

Keep in mind assumes you’ll only have one link per page with the same
label … if you think that won’t be the case, you’ll probably want
ensure the ids generated inside the helper are unique; using object_id
would be a simple way to do so.