# The field capture does not exist error in a plugin

**URL:** <https://www.ruby-forum.com/t/the-field-capture-does-not-exist-error-in-a-plugin/121974>\
**Category:** Rails\
**Created:** [December 3, 2007, 3:23pm UTC](https://www.ruby-forum.com/t/the-field-capture-does-not-exist-error-in-a-plugin/121974 "2007-12-03T15:23:36Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![alan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/a87d85/32.png) [@alan](https://www.ruby-forum.com/u/alan)\
**Post date:** [December 3, 2007, 3:23pm UTC](https://www.ruby-forum.com/t/the-field-capture-does-not-exist-error-in-a-plugin/121974/1 "2007-12-03T15:23:36Z")

</div>

Hi all,

I am writing a plugin with some view helpers. The helper method uses a  
class internally to define the behaviour, but I can’t use content\_tag  
with a block inside that class.

This is the following code:

module Microformat  
module ViewHelpers

```
# User will type:
# <% geo_for location, "Location:", :geo_tag => :div, :internal_tag

```

=\> :span do |g| %\>  
# \<% g.latitude "Latitude: #{location.latitude}, " %\>  
# \<% g.longitude “Longitude: #{location.longitude}” %\>  
# \<% end %\>

```
# Output
# <div class="geo">GEO:
# <span class="latitude">342.386013</span>,
# <span class="longitude">-90.082932</span>
# </div>

def geo_for(object, text, options = {}, &proc)
  raise ArgumentError, "Missing block" unless block_given?
  containing_tag = options.delete(:tag) || :div
  internal_tag = options.delete(:internal_tag) || :span
  concat(tag(containing_tag, { :class => "geo" }, true),

```

proc.binding)  
concat(text, proc.binding)  
yield MicroformatCreator::GeoInternal.new(internal\_tag, object)  
concat("\</#{containing\_tag}\>", proc.binding)  
end

end

module MicroformatCreator

```
class InvalidMicroformatField < StandardError
end

class Microformat
  include ActionView::Helpers::TagHelper

  def initialize(tag, object)
    @internal_tag, @object = tag, object
  end

  def method_missing(name, *args)
    raise InvalidMicroformatField, "The field #{name} does not

```

exist" unless  
@object.attribute\_names.include?(name.to\_s)  
text = args.pop  
content\_tag @internal\_tag, :class =\> name do  
text unless text.nil?  
end  
end  
end

```
class GeoInternal < Microformat

end

```

end  
end

The error happens with the content\_tag of method\_missing of the  
Microformat class, the exact message is ‘The field capture does not  
exist’ and the module Microformat::ViewHelpers its included to  
ActionView::Base when the plugin loads. content\_tag as I’ve said works  
if it is not passed a block.

Any ideas on how to get working content\_tag in this situation would be  
great!

Thanks,

Alan

---

<div class="post-metadata">

**Author:** ![alan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/a87d85/32.png) [@alan](https://www.ruby-forum.com/u/alan)\
**Post date:** [December 3, 2007, 8:27pm UTC](https://www.ruby-forum.com/t/the-field-capture-does-not-exist-error-in-a-plugin/121974/2 "2007-12-03T20:27:25Z")

</div>

Got past the field error by adding this

class Microformat  
include ActionView::Helpers::TagHelper  
include ActionView::Helpers::CaptureHelper  
include ActionView::Helpers::TextHelper

but now \_erbout is not defined in the scope of GeoInternal, are there  
any way to make it available for the content\_tag of the method\_missing?

Alan
