Ruby on Rails Friday, September 30, 2011

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:
<many words>;<more words>;<maybe even more words>;

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.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

No comments:

Post a Comment