Hi, I''ve made a simple plugin for Rails 2.0 to generate options for <select> tag. After installed, add the ''acts_as_options'' line to your model: class Brand acts_as_options end By default ActsAsOptions suppose you have a ''name'' column and a ''id'' column in your table, you can change this of course(see below). After the declaration whenever you need options for a select in form, simply: f.select :brands, Brand.find_as_options or select_tag :brands, Brand.find_as_options you can specify the name and value column when declaration or find: acts_as_options :stub, :id # will generate <option value=''<%= brand.id %>''><%= brand.stub %></option> or Brand.find_as_options :stub, :id Best Jan -- jan=callcc{|jan|jan};jan.call(jan)
Hi, I''ve made a simple plugin for Rails 2.0 to generate options for <select> tag. script/plugin install http://janx.googlecode.com/svn/trunk/acts_as_options After installed, add the ''acts_as_options'' line to your model: class Brand acts_as_options end By default ActsAsOptions suppose you have a ''name'' column and a ''id'' column in your table, you can change this of course(see below). After the declaration whenever you need options for a select in form, simply: f.select :brands, Brand.find_as_options or select_tag :brands, Brand.find_as_options you can specify the name and value column when declaration or find: acts_as_options :stub, :id # will generate <option value=''<%= brand.id %>''><%= brand.stub %></option> or Brand.find_as_options :stub, :id Best Jan -- jan=callcc{|jan|jan};jan.call(jan)
what''s the difference with acts_as_dropdown? On Sun, Apr 20, 2008 at 8:02 PM, Xie Hanjian <jan.h.xie-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hi, > > I''ve made a simple plugin for Rails 2.0 to generate options for <select> > tag. After installed, add the ''acts_as_options'' line to your model: > > class Brand > acts_as_options > end > > By default ActsAsOptions suppose you have a ''name'' column and a ''id'' > column in your table, you can change this of course(see below). > > After the declaration whenever you need options for a select in form, > simply: > > f.select :brands, Brand.find_as_options > > or > > select_tag :brands, Brand.find_as_options > > you can specify the name and value column when declaration or find: > > acts_as_options :stub, :id # will generate <option value=''<%= brand.id > %>''><%= brand.stub %></option> > > or > > Brand.find_as_options :stub, :id > > Best > Jan > > -- > jan=callcc{|jan|jan};jan.call(jan) >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
umm... I reinvented a wheel :-) Thanks Jan * sishen <yedingding-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> [2008-04-21 16:56:06 +0800]:> what''s the difference with acts_as_dropdown? > > On Sun, Apr 20, 2008 at 8:02 PM, Xie Hanjian <jan.h.xie-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > Hi, > > > > I''ve made a simple plugin for Rails 2.0 to generate options for <select> > > tag. After installed, add the ''acts_as_options'' line to your model: > > > > class Brand > > acts_as_options > > end > > > > By default ActsAsOptions suppose you have a ''name'' column and a ''id'' > > column in your table, you can change this of course(see below). > > > > After the declaration whenever you need options for a select in form, > > simply: > > > > f.select :brands, Brand.find_as_options > > > > or > > > > select_tag :brands, Brand.find_as_options > > > > you can specify the name and value column when declaration or find: > > > > acts_as_options :stub, :id # will generate <option value=''<%= brand.id > > %>''><%= brand.stub %></option> > > > > or > > > > Brand.find_as_options :stub, :id > > > > Best > > Jan > > > > -- > > jan=callcc{|jan|jan};jan.call(jan) > > > > --~--~---------~--~----~------------~-------~--~----~ > 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 > -~----------~----~----~----~------~----~------~--~--- >-- jan=callcc{|jan|jan};jan.call(jan)