Topic: How to add new methods to the form_helper class?

I tried to figure out how to add new methods to the form_helper class.

In my case, an attrubite had 3 possible values.

I want to add a method that create 3 radio buttons.

Finally I want to be able to use this in my erb file:

<% form_for(@modelname) do |f| %>
  ...
  <%= f.a_b_or_c :fieldname %>
  ...
<% end %>

Where do I create the file, where do I define the method, and how can I access the property and value in the form?
A good example that is easy to understand would help a lot.

Egon

Last edited by JavaBar (2011-05-11 06:15:36)

Re: How to add new methods to the form_helper class?

I think I've found a good blog for my problem:

http://blog.jepamedia.org/2008/12/20/ra … -elements/

Egon

Re: How to add new methods to the form_helper class?

Ugh, it does not work, it causes this error:

ActionView::TemplateError (undefined method `form_for' for #<ActionView::Base:0x7f93180a5c50>)

Why is the method missing now? Please help!

Egon