@make_num = (1..50).entries something like? <%= f.collection_select(:make_num, @make_num.collect {|c| [c, c]}) %> i get wrong number of arguments (2 for 4) thanks! -- 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?hl=en -~----------~----~----~----~------~----~------~--~---
Ryan Bigg (Radar)
2008-May-22 05:39 UTC
Re: create a collection select from a array of numbers 1-50
<%= f.select "make_num", 1..50 %> On Thu, May 22, 2008 at 3:00 PM, Scott Kulik < rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > @make_num = (1..50).entries > > something like? > > <%= f.collection_select(:make_num, @make_num.collect {|c| [c, c]}) %> > > i get wrong number of arguments (2 for 4) > > thanks! > -- > Posted via http://www.ruby-forum.com/. > > > >-- Appreciated my help? Recommend me on Working With Rails http://workingwithrails.com/person/11030-ryan-bigg --~--~---------~--~----~------------~-------~--~----~ 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?hl=en -~----------~----~----~----~------~----~------~--~---
Scott Kulik
2008-May-22 05:48 UTC
Re: create a collection select from a array of numbers 1-50
Ryan Bigg wrote:> <%= f.select "make_num", 1..50 %> >great thanks!! sometimes things are just too easy. -- 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?hl=en -~----------~----~----~----~------~----~------~--~---
Scott Kulik
2008-May-23 22:35 UTC
Re: create a collection select from a array of numbers 1-50
what if i want to add a default value of null at the top if that field is not applicable (with a label of N/A)? something like: <%= f.select(:level, 1..200 + "N/A") %> -- 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?hl=en -~----------~----~----~----~------~----~------~--~---
Pardee, Roy
2008-May-23 22:45 UTC
Re: create a collection select from a array of numbers 1-50
I think that''d be something like: <%= f.select(:level, 1..200, {:prompt=> "N/A"}) %> (Not sure if those curly braces are necessary, but they shouldn''t hurt...) -----Original Message----- From: rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org [mailto:rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org] On Behalf Of Scott Kulik Sent: Friday, May 23, 2008 3:35 PM To: rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Subject: [Rails] Re: create a collection select from a array of numbers 1-50 what if i want to add a default value of null at the top if that field is not applicable (with a label of N/A)? something like: <%= f.select(:level, 1..200 + "N/A") %> -- 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Scott Kulik
2008-May-23 23:35 UTC
Re: create a collection select from a array of numbers 1-50
Roy Pardee wrote:> I think that''d be something like: > > <%= f.select(:level, 1..200, {:prompt=> "N/A"}) %> > > (Not sure if those curly braces are necessary, but they shouldn''t > hurt...)cool thanks! -- 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?hl=en -~----------~----~----~----~------~----~------~--~---
Scott Kulik
2008-May-23 23:40 UTC
Re: create a collection select from a array of numbers 1-50
Scott Kulik wrote:> Roy Pardee wrote: >> I think that''d be something like: >> >> <%= f.select(:level, 1..200, {:prompt=> "N/A"}) %> >> >> (Not sure if those curly braces are necessary, but they shouldn''t >> hurt...) > > cool thanks!oops one more thing. what if i want the option to be available when editing the item too? -- 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?hl=en -~----------~----~----~----~------~----~------~--~---
Pardee, Roy
2008-May-24 00:43 UTC
Re: create a collection select from a array of numbers 1-50
Hmmm--that''s different I think. With :prompt, the string you give isn''t actually stored in the db--it''ll get translated to a null. You can use the very same call in your edit view, and again nulls should be translated into the prompt value. But if you really want to store "N/A" in the db, you''ll have to do something like: # In your model, say: class MyModel < ActiveRecord::Base ALLOWABLE_LEVELS = (1..200).to_a << "N/A" end # and then: <%= f.select(:level, MyModel::ALLOWABLE_LEVELS) %> Mind you, your level field will have to accept strings if you do this... HTH, -Roy -----Original Message----- From: rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org [mailto:rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org] On Behalf Of Scott Kulik Sent: Friday, May 23, 2008 4:41 PM To: rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org Subject: [Rails] Re: create a collection select from a array of numbers 1-50 Scott Kulik wrote:> Roy Pardee wrote: >> I think that''d be something like: >> >> <%= f.select(:level, 1..200, {:prompt=> "N/A"}) %> >> >> (Not sure if those curly braces are necessary, but they shouldn''t >> hurt...) > > cool thanks!oops one more thing. what if i want the option to be available when editing the item too? -- 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Scott Kulik
2008-May-24 01:37 UTC
Re: create a collection select from a array of numbers 1-50
Roy Pardee wrote:> Hmmm--that''s different I think. With :prompt, the string you give isn''t > actually stored in the db--it''ll get translated to a null. You can use > the very same call in your edit view, and again nulls should be > translated into the prompt value. But if you really want to store "N/A" > in the db, you''ll have to do something like: > > # In your model, say: > class MyModel < ActiveRecord::Base > ALLOWABLE_LEVELS = (1..200).to_a << "N/A" > end > > # and then: > <%= f.select(:level, MyModel::ALLOWABLE_LEVELS) %> > > Mind you, your level field will have to accept strings if you do this... > > HTH, > > -Roythanks again roy that helps. the only thing is that edit shows the prompt N/A only if the value is already null. if i set the level to 3 and then edit. there is no more N/A to chose from. but yea i would want the value to be stored as NULL when selecting N/A. -- 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?hl=en -~----------~----~----~----~------~----~------~--~---