Gsubbing on a view/symbol

I would love a full drop-in answer (hand me a fish), but I this might be
a
matter of pointing me to where I need to RTFM (teach me to fish).

I have a form with a text_area:

<%= f.text_area :modified_strategy, :options=>{:cols => 80} %>

the string represented by :modify_strategy is comprised of a pattern:
;;;

This string is a representation of what was originally three lines with
“\n”.
So to properly render them in a text_area I would want to do something
like:
gsub(";","\n")
and then reverse this in the Model before_save.

Unfortunately something as simple as

… :modifed_strategy.gsub(";", “\n”) …

returns an error:
undefined method `gsub’ for :modified_strategy:Symbol

How do I change “;” to “\n” on the string represented by
:modified_strategy?
Where to next because I guess I’m really missing something about Symbols
or
Views.

The :modified_strategy is just a symbol that tells the helper which
method
to call on your object to get the name/value of the textarea.

If you want to manually change the value of the textarea, you can
overwrite
the value attribute:

f.text_area(:modify_strategy , :value =>
f.object.modify_strategy.gsub(";",
“\n”), :cols => 80)

wonderful.
still iffy on this Symbol concept but it seems I am not alone. rtfm!

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