I''m new to rails and was playing with a simple model with acts_as_threaded. The sql is... CREATE TABLE bobbits ( id integer NOT NULL DEFAULT nextval(''destination_countrycode_id_seq''::regclass), name character varying(100) NOT NULL, description text, parent_id integer, CONSTRAINT bobbits_pkey PRIMARY KEY (id) ) and the only change i made after generating scaffolding was of course: class Bobbit < ActiveRecord::Base acts_as_tree :order => "name" end Now I expected that rendering of a bobbit in the browser would present an drop-down list for parent, but no such luck. Whats up? --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
On Jun 30, 8:53 pm, dailer <d.sai...-Wuw85uim5zDR7s880joybQ@public.gmane.org> wrote:> I''m new to rails and was playing with a simple model with > acts_as_threaded. The sql is... > > CREATE TABLE bobbits > ( > id integer NOT NULL DEFAULT > nextval(''destination_countrycode_id_seq''::regclass), > name character varying(100) NOT NULL, > description text, > parent_id integer, > CONSTRAINT bobbits_pkey PRIMARY KEY (id) > ) > > and the only change i made after generating scaffolding was of course: > > class Bobbit < ActiveRecord::Base > acts_as_tree :order => "name" > end > > Now I expected that rendering of a bobbit in the browser would present > an drop-down list for parent, but no such luck. Whats up?could someone at least confirm that I should see a dropdown? --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
dailer wrote:> On Jun 30, 8:53 pm, dailer <d.sai...-Wuw85uim5zDR7s880joybQ@public.gmane.org> wrote: >> CONSTRAINT bobbits_pkey PRIMARY KEY (id) >> ) >> >> and the only change i made after generating scaffolding was of course:> could someone at least confirm that I should see a dropdown?i don''t know of a dropdown that should be populated automatically with "generate scaffold", but i haven''t used the ''generate scaffold'' in a long time, so i may be way outdated. to answer your question though, i would have to say i personally don''t know of any dropdown that should be generated when creating an association. -- 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 -~----------~----~----~----~------~----~------~--~---
> generated when creating an association.... or acts_as_tree etc -- 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 -~----------~----~----~----~------~----~------~--~---
On Jun 30, 8:53 pm, dailer <d.sai...-Wuw85uim5zDR7s880joybQ@public.gmane.org> wrote:> I''m new to rails and was playing with a simple model with > acts_as_threaded. The sql is... > > CREATE TABLE bobbits > ( > id integer NOT NULL DEFAULT > nextval(''destination_countrycode_id_seq''::regclass), > name character varying(100) NOT NULL, > description text, > parent_id integer, > CONSTRAINT bobbits_pkey PRIMARY KEY (id) > ) > > and the only change i made after generating scaffolding was of course: > > class Bobbit < ActiveRecord::Base > acts_as_tree :order => "name" > end > > Now I expected that rendering of a bobbit in the browser would present > an drop-down list for parent, but no such luck. Whats up?could someone at least confirm that I should see a dropdown? --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
On Jul 1, 7:23 am, Shai Rosenfeld <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > generated when creating an association. > > ... or acts_as_tree etc > > -- > Posted viahttp://www.ruby-forum.com/.ah, I see my mistake was skimming the recipe example and I missed the part where the view was updated with the select/dropdown. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
No. acts_as_tree is an extension to ActiveRecord -- the objects- wrapping-db mechanism in rails (Model). Dropdowns are a function of the view. By default, the scaffold will generate a text_column for almost everything but date, datetime, and boolean fields. If you want a dropdown for parent, you need to change the scaffolded field that probably looks like: <p> <b>Parent</b> <%= text_field f.parent_id %> <----- this one </p> To something along the lines of.... <p> <b>Parent</b> <%= select f.parent_id, Bobbit.find(:all, :order=>''name'').collect{| bobbit| [bobbit.name, bobbit.id]} %> <p> The select object accepts the name of the attribute to be filled (parent_id), and an enumerable set of options. In the example above, you''re retrieving all the Bobbits, ordered by their name, and creating an array of name/val pairs to be displayed in the dropdown. HTH, AndyV On Jul 1, 7:30 am, dailer <d.sai...-Wuw85uim5zDR7s880joybQ@public.gmane.org> wrote:> On Jun 30, 8:53 pm, dailer <d.sai...-Wuw85uim5zDR7s880joybQ@public.gmane.org> wrote: > > > > > I''m new to rails and was playing with a simple model with > > acts_as_threaded. The sql is... > > > CREATE TABLE bobbits > > ( > > id integer NOT NULL DEFAULT > > nextval(''destination_countrycode_id_seq''::regclass), > > name character varying(100) NOT NULL, > > description text, > > parent_id integer, > > CONSTRAINT bobbits_pkey PRIMARY KEY (id) > > ) > > > and the only change i made after generating scaffolding was of course: > > > class Bobbit < ActiveRecord::Base > > acts_as_tree :order => "name" > > end > > > Now I expected that rendering of a bobbit in the browser would present > > an drop-down list for parent, but no such luck. Whats up? > > could someone at least confirm that I should see a dropdown?--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---