I have a table that contains currencies I support which has the columns: id, ch (the character to display when showing currency) name (the human name of the currency ...) This table is currently loaded with these values: currencies: Name ch -------- -------------- U.S.D $ Euro &euro G.B.P. £ I created a method in my ''currency'' model called ''menustr'' which I use in collection_select to show the currency options: def menustr return ch + " " + name end I then use this in my form template: <td><label for="customer_def_cur_pref">Default Currency: </label></td> <td><%= collection_select("customer", :def_cur_pref, @zcurtype, :ch, :menustr) %></td> where @zcurtype is an array containing all the currencies in the currencies table. Instead of putting the pretty html version of £ and &euro in my pull down menu, collection_select''s form is quoting them and I still see the "£" and "&euro" text. Anyone have a way to work around this? Thanks! --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
Mark Reginald James
2006-Sep-27 00:57 UTC
Re: collection_select is quoting my text_method text ?
dmack wrote:> I have a table that contains currencies I support which has the > columns: > id, > ch (the character to display when showing currency) > name (the human name of the currency ...) > > This table is currently loaded with these values: > > currencies: > > Name ch > -------- -------------- > U.S.D $ > Euro &euro > G.B.P. £ > > I created a method in my ''currency'' model called ''menustr'' which I use > in collection_select to show the currency options: > > def menustr > return ch + " " + name > end > > I then use this in my form template: > > <td><label for="customer_def_cur_pref">Default Currency: > </label></td> > <td><%= collection_select("customer", :def_cur_pref, @zcurtype, > :ch, :menustr) %></td> > > where @zcurtype is an array containing all the currencies in the > currencies table. > > Instead of putting the pretty html version of £ and &euro in my > pull down menu, collection_select''s form is quoting them and I still > see the "£" and "&euro" text.Append a semicolon to the values in your table that are HTML symbols. -- We develop, watch us RoR, in numbers too big to ignore. --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
Mark Reginald James wrote:> dmack wrote: > > I have a table that contains currencies I support which has the > > columns: > > id, > > ch (the character to display when showing currency) > > name (the human name of the currency ...) > > > > This table is currently loaded with these values: > > > > currencies: > > > > Name ch > > -------- -------------- > > U.S.D $ > > Euro &euro > > G.B.P. £ > > > > I created a method in my ''currency'' model called ''menustr'' which I use > > in collection_select to show the currency options: > > > > def menustr > > return ch + " " + name > > end > > > > I then use this in my form template: > > > > <td><label for="customer_def_cur_pref">Default Currency: > > </label></td> > > <td><%= collection_select("customer", :def_cur_pref, @zcurtype, > > :ch, :menustr) %></td> > > > > where @zcurtype is an array containing all the currencies in the > > currencies table. > > > > Instead of putting the pretty html version of £ and &euro in my > > pull down menu, collection_select''s form is quoting them and I still > > see the "£" and "&euro" text. > > Append a semicolon to the values in your table that are HTML symbols.Thanks for the response. I have the semi-colon on the end of my values for ''ch'' in my currencies table. If I list my table using the default scaffolding, I get what I want: Listing currencies (sorry for the formatting) Name Ch Menustr Actions USD $ $; USD Show Edit Destroy Euro ; Euro Show Edit Destroy GBP £ £; GBP Show Edit Destroy However, when I populate a pull-down menu using collection_select, the symbol reverts back to either £ or &euro which doesn''t look as pretty :-( My controller does this: def new @customer = Customer.new @zcurtype= Currency.find(:all) end and the chunk in the form template does this for the pull-down: <label for="customer_def_cur_pref">Default Currency: </label></td> <%= collection_select("customer", :def_cur_pref, @zcurtype, :ch, :menustr) %> ... Looking at the generated html, you can see the & ... prefixes on the code plus the extra semi-colon I added to see if it would help :-) <label for="customer_def_cur_pref">Default Currency: </label> <select id="customer_def_cur_pref" name="customer[def_cur_pref]"> <option value="$" selected="selected">$; USD</option> <option value="&euro;">&euro;; Euro</option> <option value="&pound;">&pound;; GBP</option> </select> --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@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 -~----------~----~----~----~------~----~------~--~---
Mark Reginald James
2006-Sep-29 04:34 UTC
Re: collection_select is quoting my text_method text ?
dmack wrote:> Thanks for the response. I have the semi-colon on the end of my values > for ''ch'' in my currencies table. If I list my table using the default > scaffolding, I get what I want: > > Listing currencies (sorry for the formatting) > Name Ch Menustr Actions > USD $ $; USD Show Edit Destroy > Euro € €; Euro Show Edit Destroy > GBP £ £; GBP Show Edit Destroy > > > However, when I populate a pull-down menu using collection_select, the > symbol reverts back to either £ or &euro which doesn''t look as > pretty :-(Yes, the Rails select options builder is calling html_escape on the option texts and values. You''ll either have to build your html options manually, or override the html_escape method. -- We develop, watch us RoR, in numbers too big to ignore. --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@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 -~----------~----~----~----~------~----~------~--~---
Mark Reginald James wrote:> > Yes, the Rails select options builder is calling html_escape on the > option texts and values. > > You''ll either have to build your html options manually, or override > the html_escape method. >Aha... So collection_select escapes html. That explains it. I will use your suggestion and build up the option lists manually. Too bad we can''t pass an :escape => false or something to collection_select. Thank you! Dan --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
Mark Reginald James wrote:> Yes, the Rails select options builder is calling html_escape on the > option texts and values. > > You''ll either have to build your html options manually, or override > the html_escape method.Mark, You are correct. I didn''t know that it did that until now but now I do. It''s too bad we can''t pass an :escape => false or something to collection_select. Thank you for you help, Dan --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
Mark Reginald James
2006-Oct-06 21:53 UTC
Re: collection_select is quoting my text_method text ?
dmack wrote:> Aha... So collection_select escapes html. That explains it. I will > use your suggestion and build up the option lists manually. > > Too bad we can''t pass an :escape => false or something to > collection_select.Good idea. While the value tag of the option must be escaped (see http://dev.rubyonrails.org/ticket/2011), the option text is html, and that need not be escaped. I''ll submit a patch. -- We develop, watch us RoR, in numbers too big to ignore. --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
dmack wrote:> This table is currently loaded with these values: > > currencies: > > Name ch > -------- -------------- > U.S.D $ > Euro &euro > G.B.P. £ > > Instead of putting the pretty html version of £ and &euro in my > pull down menu, collection_select''s form is quoting them and I still > see the "£" and "&euro" text. > > Anyone have a way to work around this? > > Thanks!here, you dropped this: '';'' try € and £ -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---