dbkbali
2010-Feb-22 07:04 UTC
Rails 2.3.5/Ruby1.8.7 Collection_Select Labels with ampersands "&"
I am having an annoying problem displaying the labels of a select box correctly where there is an ampersand contained within the label string. On a form being rendered with the form_for helper the collection_select reads data from a Mysql 5.075 database the text stored in the database is "Surabaya & Surrounding Areas" when rendered and displayed in firefox 3.6 or safari is is displaying as "Surabaya %amp; Surrounding Areas". The code used to render the select is as follows: <%= f.collection_select :parent_id, Destination.roots, :id, :name, {:include_blank => true} %> I have tried adding a h(:name) and also storing && in the database but it still will not display the ampersand correctly. Have searched on google for what I thought would be a simple solution but cant find anything that solves this. If anyone has a solution it will be much appreciated. many thanks, David -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Boby Ertanto
2010-Feb-22 07:08 UTC
Re: Rails 2.3.5/Ruby1.8.7 Collection_Select Labels with ampersands "&"
You can try to change "Surabaya & Surrounding Areas" in your database to "Surabaya & Surrounding Areas" Best Regards, Boby Ertanto On Mon, Feb 22, 2010 at 3:04 PM, dbkbali <dbkrett-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I am having an annoying problem displaying the labels of a select box > correctly where there is an ampersand contained within the label > string. > > On a form being rendered with the form_for helper the > collection_select reads data from a Mysql 5.075 database the text > stored in the database is "Surabaya & Surrounding Areas" when rendered > and displayed in firefox 3.6 or safari is is displaying as "Surabaya > %amp; Surrounding Areas". > > The code used to render the select is as follows: > > <%= f.collection_select :parent_id, Destination.roots, :id, :name, > {:include_blank => true} %> > > I have tried adding a h(:name) and also storing && in the database but > it still will not display the ampersand correctly. Have searched on > google for what I thought would be a simple solution but cant find > anything that solves this. > > If anyone has a solution it will be much appreciated. > > many thanks, > > David > > -- > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> > . > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. > >-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
dbkbali
2010-Feb-22 17:05 UTC
Re: Rails 2.3.5/Ruby1.8.7 Collection_Select Labels with ampersands "&"
Boby, tried that earlier and that produced "Surabaya &amp; Surrounding Areas". It looks like I might have to write a custom helper method or hack the form_for helper method, which I was hoping to avoid. If you or another reader has a better way your feedback would be much appreciated. Thx anyway for your suggestion. David On Feb 22, 3:08 pm, Boby Ertanto <cool.erta...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> You can try to change "Surabaya & Surrounding Areas" in your database to > "Surabaya & Surrounding Areas" > > Best Regards, > Boby Ertanto > > On Mon, Feb 22, 2010 at 3:04 PM, dbkbali <dbkr...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > I am having an annoying problem displaying the labels of a select box > > correctly where there is an ampersand contained within the label > > string. > > > On a form being rendered with the form_for helper the > > collection_select reads data from a Mysql 5.075 database the text > > stored in the database is "Surabaya & Surrounding Areas" when rendered > > and displayed in firefox 3.6 or safari is is displaying as "Surabaya > > %amp; Surrounding Areas". > > > The code used to render the select is as follows: > > > <%= f.collection_select :parent_id, Destination.roots, :id, :name, > > {:include_blank => true} %> > > > I have tried adding a h(:name) and also storing && in the database but > > it still will not display the ampersand correctly. Have searched on > > google for what I thought would be a simple solution but cant find > > anything that solves this. > > > If anyone has a solution it will be much appreciated. > > > many thanks, > > > David > > > -- > > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > > To unsubscribe from this group, send email to > > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> > > . > > For more options, visit this group at > >http://groups.google.com/group/rubyonrails-talk?hl=en. > >-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org 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.
dbkbali
2010-Feb-22 17:43 UTC
Re: Rails 2.3.5/Ruby1.8.7 Collection_Select Labels with ampersands "&"
Problem solved after debugging further realized my select option values were being created in Javascript from an erb file, the problem was created by using <%= %> instead of <%- %> when creating the javascript to send to the client. Learning something new everyday! On Feb 23, 1:05 am, dbkbali <dbkr...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Boby, > > tried that earlier and that produced "Surabaya &amp; Surrounding > Areas". > > It looks like I might have to write a custom helper method or hack the > form_for helper method, which I was hoping to avoid. > > If you or another reader has a better way your feedback would be much > appreciated. > > Thx anyway for your suggestion. > > David > > On Feb 22, 3:08 pm, Boby Ertanto <cool.erta...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > You can try to change "Surabaya & Surrounding Areas" in your database to > > "Surabaya & Surrounding Areas" > > > Best Regards, > > Boby Ertanto > > > On Mon, Feb 22, 2010 at 3:04 PM, dbkbali <dbkr...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > I am having an annoying problem displaying the labels of a select box > > > correctly where there is an ampersand contained within the label > > > string. > > > > On a form being rendered with the form_for helper the > > > collection_select reads data from a Mysql 5.075 database the text > > > stored in the database is "Surabaya & Surrounding Areas" when rendered > > > and displayed in firefox 3.6 or safari is is displaying as "Surabaya > > > %amp; Surrounding Areas". > > > > The code used to render the select is as follows: > > > > <%= f.collection_select :parent_id, Destination.roots, :id, :name, > > > {:include_blank => true} %> > > > > I have tried adding a h(:name) and also storing && in the database but > > > it still will not display the ampersand correctly. Have searched on > > > google for what I thought would be a simple solution but cant find > > > anything that solves this. > > > > If anyone has a solution it will be much appreciated. > > > > many thanks, > > > > David > > > > -- > > > 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-/JYPxA39Uh4Ykp1iOSErHA@public.gmane.orgm. > > > To unsubscribe from this group, send email to > > > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> > > > . > > > For more options, visit this group at > > >http://groups.google.com/group/rubyonrails-talk?hl=en. > >-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org 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.