Also I found another place to add it and it inserted some backslahes
so the orignal text is 'atlanta boston'
I'm trying to insert 2 '' between atlanta and boston which works fine
standalone but in my app (inserted into a query) it comes out as such
'boston\'\'atlanta'
But if I leave the regex out it's as shown above
Stuart
···
On 10/9/06, Dark Ambient <sambient@gmail.com> wrote:
I googled around on this one but found nothing. Anyone know what these
error means ?
I'm trying to use it in a form field :
text_field takes two arguments, the first is the object it represents,
and the second is the attribute of that object that the value will be
saved into/pulled out from.
It seems that you want to massage that value before it gets inserted
into the form field, right? Or is it after it gets saved?
In the former case, you can (probably!) specify a value manually, like
so:
>
> I googled around on this one but found nothing. Anyone know what these
> error means ?
> I'm trying to use it in a form field :
>
> <%= text_field(:search,:city.gsub(/\s/, "''")) %></fieldset>
>
> But also found the same error when using it on an instance variable.
>
> TIA
> Stuart
Also I found another place to add it and it inserted some backslahes
so the orignal text is 'atlanta boston'
I'm trying to insert 2 '' between atlanta and boston which works fine
standalone but in my app (inserted into a query) it comes out as such
'boston\'\'atlanta'
But if I leave the regex out it's as shown above
Well the regex isn't doing what you think it's doing. Rails automagically
converts :city, to the value of a field in your model named City. When you
say :city.gsub Ruby reads this as "do a gsub on the symbol :city", it
doesn't know that later on Rails will make that a string with another
value. IMO the easiest way around this would be to not use the helper and
do something like:
Yeah, I've thought about this way but it would cause more problems for me
later on.
Seems though that when I put right before it goes into the select statement
either AR or mysql is adding the backslahes for some reason.
Stuart
···
On 10/9/06, Tanner Burson <tanner.burson@gmail.com> wrote:
On 10/9/06, Dark Ambient <sambient@gmail.com> wrote:
>
> On 10/9/06, Dark Ambient <sambient@gmail.com> wrote:
> >
> > I googled around on this one but found nothing. Anyone know what
these
> > error means ?
> > I'm trying to use it in a form field :
> >
> > <%= text_field(:search,:city.gsub(/\s/, "''")) %></fieldset>
> >
> > But also found the same error when using it on an instance variable.
> >
> > TIA
> > Stuart
>
> Also I found another place to add it and it inserted some backslahes
> so the orignal text is 'atlanta boston'
> I'm trying to insert 2 '' between atlanta and boston which works fine
> standalone but in my app (inserted into a query) it comes out as such
> 'boston\'\'atlanta'
> But if I leave the regex out it's as shown above
Well the regex isn't doing what you think it's doing. Rails automagically
converts :city, to the value of a field in your model named City. When
you
say :city.gsub Ruby reads this as "do a gsub on the symbol :city", it
doesn't know that later on Rails will make that a string with another
value. IMO the easiest way around this would be to not use the helper and
do something like: