I am new to Ruby On Rails. I have scaffolded a few screens for a website''s administration pages. For example, right now I have (etc., etc.): admin/companies admin/regions admin/countries I am going back and editing the scaffolded screens. I need to know how to add a dropdown list to the admin\regions\_form.html.erb page that would show the countries I have added using admin/countries/new. -- 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-/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 https://groups.google.com/groups/opt_out.
On Sep 25, 2012, at 6:44 PM, DONEIN NET wrote:> I am new to Ruby On Rails. > > I have scaffolded a few screens for a website''s administration pages. > > For example, right now I have (etc., etc.): > > admin/companies > admin/regions > admin/countries > > I am going back and editing the scaffolded screens. > > I need to know how to add a dropdown list to the > admin\regions\_form.html.erb page that would show the countries I have > added using admin/countries/new.If your region belongs_to country, then you could do something like this (inside a form_for for the region): <%= f.collection_select :country_id, Country.order(:name), :id, :name %> Walter -- 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 https://groups.google.com/groups/opt_out.
Walter Davis wrote in post #1077557:> On Sep 25, 2012, at 6:44 PM, DONEIN NET wrote: > >> I am going back and editing the scaffolded screens. >> >> I need to know how to add a dropdown list to the >> admin\regions\_form.html.erb page that would show the countries I have >> added using admin/countries/new. > > If your region belongs_to country, then you could do something like this > (inside a form_for for the region): > > <%= f.collection_select :country_id, Country.order(:name), :id, :name %> > > WalterThanks! That got me going in the right direction. The one tricky part was that my items are in the admin folder, so this ended up being the format: <%= f.collection_select :country, Admin::Country.order(:sort_order,:country), :id, :country %> -- 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-/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 https://groups.google.com/groups/opt_out.
I have now ran into another issue. I have a field like this on my _form.html page: <%= f.collection_select :address_region, Admin::Region.order(:region), :id, :region, :include_blank => true %> This works fine, but if I don''t select a value (which is okay) I can not later edit the record. If I try to, I get: Couldn''t find Admin::Region without an ID Is there anyway to edit the form if users have left the field blank? -- 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-/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 https://groups.google.com/groups/opt_out.