# Drop down menu

**URL:** <https://www.ruby-forum.com/t/drop-down-menu/192700>\
**Category:** Rails\
**Created:** [August 4, 2010, 10:13am UTC](https://www.ruby-forum.com/t/drop-down-menu/192700 "2010-08-04T10:13:09Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![disruptive](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/49beb7/32.png) [@disruptive](https://www.ruby-forum.com/u/disruptive)\
**Post date:** [August 4, 2010, 10:13am UTC](https://www.ruby-forum.com/t/drop-down-menu/192700/1 "2010-08-04T10:13:09Z")

</div>

I have a series of countries listed in a table in the following form:

id, country\_name

I want to pull these in and I’m trying everything under the sun from a  
variety of different peoples pages. I just cannot get anything working  
at all. I have tried pulling all the records in the the ctrl.rb file  
with:

@country\_list = Country.find\_all

I get the following:

undefined method `find\_all’ for #Class:0xb657a3a8

I have put this in the following method

def new  
@usr = Usr.new  
@country\_list = Country.find\_all  
respond\_to do |format|  
format.html # new.html.erb  
format.xml { render :xml =\> @usr }  
end  
end

I’m not fussy about the methodology, I simply want a drop down list the  
easiest and simplest way…I have tried a number of other approaching,  
but I wonder if there are problems with RoR versions?

Thanks in advance.

---

<div class="post-metadata">

**Author:** ![disruptive](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/49beb7/32.png) [@disruptive](https://www.ruby-forum.com/u/disruptive)\
**Post date:** [August 4, 2010, 10:14am UTC](https://www.ruby-forum.com/t/drop-down-menu/192700/2 "2010-08-04T10:14:46Z")

</div>

disruptive tech wrote:

> I have a series of countries listed in a table in the following form:
> 
> id, country\_name
> 
> I want to pull these in and I’m trying everything under the sun from a  
> variety of different peoples pages. I just cannot get anything working  
> at all. I have tried pulling all the records in the the ctrl.rb file  
> with:
> 
> @country\_list = Country.find\_all
> 
> I get the following:
> 
> undefined method `find\_all’ for #Class:0xb657a3a8
> 
> I have put this in the following method
> 
> def new  
> @usr = Usr.new  
> @country\_list = Country.find\_all  
> respond\_to do |format|  
> format.html # new.html.erb  
> format.xml { render :xml =\> @usr }  
> end  
> end
> 
> I’m not fussy about the methodology, I simply want a drop down list the  
> easiest and simplest way…I have tried a number of other approaching,  
> but I wonder if there are problems with RoR versions?
> 
> Thanks in advance.

I also tried directly in the view:

collection\_select ‘country’, ‘type’, Type.find(:all), :type\_name, :id

with nothing in the controller.

---

<div class="post-metadata">

**Author:** ![disruptive](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/49beb7/32.png) [@disruptive](https://www.ruby-forum.com/u/disruptive)\
**Post date:** [August 4, 2010, 10:32am UTC](https://www.ruby-forum.com/t/drop-down-menu/192700/3 "2010-08-04T10:32:15Z")

</div>

I’m also trying this:

## controller

def new  
@usr = Usr.new  
@country\_list = Country.find(:all, :order=\>“country\_name”)  
respond\_to do |format|  
format.html # new.html.erb  
format.xml { render :xml =\> @usr }  
end  
end

## and in view

\<%= collection\_select(:country, :id, @country\_list, :id, :country\_name,  
options ={:prompt =\> “-Select a cnt”}, :class =\>“country”) %\>

I get the following on loading a new.html.erb

You have a nil object when you didn’t expect it!  
You might have expected an instance of Array.  
The error occurred while evaluating nil.map

Any ideas? Thanks

B

---

<div class="post-metadata">

**Author:** ![disruptive](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/49beb7/32.png) [@disruptive](https://www.ruby-forum.com/u/disruptive)\
**Post date:** [August 4, 2010, 11:56am UTC](https://www.ruby-forum.com/t/drop-down-menu/192700/4 "2010-08-04T11:56:17Z")

</div>

Colin L. wrote:

> On 4 August 2010 09:32, disruptive tech [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:
> 
> > ï¿½ ï¿½ ï¿½format.xml ï¿½{ render :xml =\> @usr }
> > 
> > You have a nil object when you didn’t expect it!  
> > You might have expected an instance of Array.  
> > The error occurred while evaluating nil.map
> 
> What happens if, rather than using collection select, you just display  
> the id and country name for each item in @country list? Doing that  
> will prove that the data is ok. I presume that the table has a  
> country\_name column.
> 
> Colin

here is a read-out - the data is there…

Listing countries

Country name  
UK Show Edit Destroy  
France Show Edit Destroy  
Germany Show Edit Destroy

describe countries;  
±-------------±-------------±-----±----±--------±---------------+  
| Field | Type | Null | Key | Default | Extra |  
±-------------±-------------±-----±----±--------±---------------+  
| id | int(11) | NO | PRI | NULL | auto\_increment |  
| country\_name | varchar(255) | YES | | NULL | |  
| created\_at | datetime | YES | | NULL | |  
| updated\_at | datetime | YES | | NULL | |  
±-------------±-------------±-----±----±--------±---------------+  
4 rows in set (0.00 sec)

select \* from countries;  
±—±-------------±--------------------±--------------------+  
| id | country\_name | created\_at | updated\_at |  
±—±-------------±--------------------±--------------------+  
| 4 | UK | 2010-08-02 16:37:43 | 2010-08-02 16:37:43 |  
| 5 | France | 2010-08-02 16:37:51 | 2010-08-02 16:37:51 |  
| 6 | Germany | 2010-08-04 08:20:03 | 2010-08-04 08:20:03 |  
±—±-------------±--------------------±--------------------+  
3 rows in set (0.00 sec)

---

<div class="post-metadata">

**Author:** ![disruptive](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/49beb7/32.png) [@disruptive](https://www.ruby-forum.com/u/disruptive)\
**Post date:** [August 4, 2010, 11:41am UTC](https://www.ruby-forum.com/t/drop-down-menu/192700/5 "2010-08-04T11:41:43Z")

</div>

On 4 August 2010 09:32, disruptive tech [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> ```
> format.xml { render :xml => @usr }
> 
> ```
> 
> You have a nil object when you didn’t expect it!  
> You might have expected an instance of Array.  
> The error occurred while evaluating nil.map

What happens if, rather than using collection select, you just display  
the id and country name for each item in @country list? Doing that  
will prove that the data is ok. I presume that the table has a  
country\_name column.

Colin

---

<div class="post-metadata">

**Author:** ![disruptive](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/49beb7/32.png) [@disruptive](https://www.ruby-forum.com/u/disruptive)\
**Post date:** [August 4, 2010, 12:12pm UTC](https://www.ruby-forum.com/t/drop-down-menu/192700/6 "2010-08-04T12:12:10Z")

</div>

On 4 August 2010 10:56, disruptive tech [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> > will prove that the data is ok. Â I presume that the table has a  
> > France Â Show Â Edit Â Destroy  
> > Germany Â Show Â Edit Â Destroy

Is that from code inserted in the view at the same point as the  
collection\_select?

Please show the complete error trace and the code around the error,  
and confirm which line of code the error is on.

Colin

---

<div class="post-metadata">

**Author:** ![disruptive](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/49beb7/32.png) [@disruptive](https://www.ruby-forum.com/u/disruptive)\
**Post date:** [August 4, 2010, 12:49pm UTC](https://www.ruby-forum.com/t/drop-down-menu/192700/7 "2010-08-04T12:49:19Z")

</div>

I can see data in the DB, but cannot seem to get this into a drop down.  
The controller code does not produce an error. But the errors would seem  
to imply that there is no data being pulled in.

---

<div class="post-metadata">

**Author:** ![disruptive](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/49beb7/32.png) [@disruptive](https://www.ruby-forum.com/u/disruptive)\
**Post date:** [August 4, 2010, 12:19pm UTC](https://www.ruby-forum.com/t/drop-down-menu/192700/8 "2010-08-04T12:19:37Z")

</div>

Extracted source (around line #23):

20: \<%= f.text\_field :email %\>  
21:

  
22: 

23: \<%= collection\_select(:country, :id, @country\_list, :id,  
:country\_name,  
24: options ={:prompt =\> “-Select a cnt”}, :class =\>“country”) %\>  
25: \<%= f.label :country %\>  
  
26: \<%= f.text\_field :country %\>  
RAILS\_ROOT: /home/brett/RoR/Apps/OpenBenefit/benefit

Application Trace | Framework Trace | Full Trace  
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.8/lib/action\_view/helpers/form\_options\_helper.rb:327:in  
`options_from_collection_for_select' /usr/lib/ruby/gems/1.8/gems/actionpack-2.3.8/lib/action_view/helpers/form_options_helper.rb:543:in `to\_collection\_select\_tag’  
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.8/lib/action\_view/helpers/form\_options\_helper.rb:162:in  
`collection_select' /home/brett/RoR/Apps/OpenBenefit/benefit/app/views/usrs/new.html.erb:23:in `\_run\_erb\_app47views47usrs47new46html46erb’  
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.8/lib/action\_view/helpers/form\_helper.rb:499:in  
`fields_for' /usr/lib/ruby/gems/1.8/gems/actionpack-2.3.8/lib/action_view/helpers/form_helper.rb:282:in `form\_for’  
/home/brett/RoR/Apps/OpenBenefit/benefit/app/views/usrs/new.html.erb:3:in  
`_run_erb_app47views47usrs47new46html46erb' /usr/lib/ruby/gems/1.8/gems/actionpack-2.3.8/lib/action_view/renderable.rb:34:in `send’  
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.8/lib/action\_view/renderable.rb:34:in  
`render' /usr/lib/ruby/gems/1.8/gems/actionpack-2.3.8/lib/action_view/base.rb:306:in `with\_template’  
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.8/lib/action\_view/renderable.rb:30:in  
`render' /usr/lib/ruby/gems/1.8/gems/actionpack-2.3.8/lib/action_view/template.rb:205:in `render\_template’  
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.8/lib/action\_view/base.rb:265:in  
`render' /usr/lib/ruby/gems/1.8/gems/actionpack-2.3.8/lib/action_view/base.rb:348:in `\_render\_with\_layout’  
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.8/lib/action\_view/base.rb:262:in  
`render' /usr/lib/ruby/gems/1.8/gems/actionpack-2.3.8/lib/action_controller/base.rb:1250:in `render\_for\_file’  
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.8/lib/action\_controller/base.rb:942:in  
`render_without_benchmark' /usr/lib/ruby/gems/1.8/gems/actionpack-2.3.8/lib/action_controller/benchmarking.rb:51:in `render’  
/usr/lib/ruby/gems/1.8/gems/activesupport-2.3.8/lib/active\_support/core\_ext/benchmark.rb:17:in  
`ms' /usr/lib/ruby/1.8/benchmark.rb:308:in `realtime’  
/usr/lib/ruby/gems/1.8/gems/activesupport-2.3.8/lib/active\_support/core\_ext/benchmark.rb:17:in  
`ms' /usr/lib/ruby/gems/1.8/gems/actionpack-2.3.8/lib/action_controller/benchmarking.rb:51:in `render’  
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.8/lib/action\_controller/mime\_responds.rb:135:in  
`send' /usr/lib/ruby/gems/1.8/gems/actionpack-2.3.8/lib/action_controller/mime_responds.rb:135 /usr/lib/ruby/gems/1.8/gems/actionpack-2.3.8/lib/action_controller/mime_responds.rb:179:in `call’  
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.8/lib/action\_controller/mime\_responds.rb:179:in  
`respond' /usr/lib/ruby/gems/1.8/gems/actionpack-2.3.8/lib/action_controller/mime_responds.rb:173:in `each’  
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.8/lib/action\_controller/mime\_responds.rb:173:in  
`respond' /usr/lib/ruby/gems/1.8/gems/actionpack-2.3.8/lib/action_controller/mime_responds.rb:107:in `respond\_to’  
/home/brett/RoR/Apps/OpenBenefit/benefit/app/controllers/usrs\_controller.rb:38:in  
`new' /usr/lib/ruby/gems/1.8/gems/actionpack-2.3.8/lib/action_controller/base.rb:1331:in `send’  
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.8/lib/action\_controller/base.rb:1331:in  
`perform_action_without_filters' /usr/lib/ruby/gems/1.8/gems/actionpack-2.3.8/lib/action_controller/filters.rb:617:in `call\_filters’  
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.8/lib/action\_controller/filters.rb:610:in  
`perform_action_without_benchmark' /usr/lib/ruby/gems/1.8/gems/actionpack-2.3.8/lib/action_controller/benchmarking.rb:68:in `perform\_action\_without\_rescue’  
/usr/lib/ruby/gems/1.8/gems/activesupport-2.3.8/lib/active\_support/core\_ext/benchmark.rb:17:in  
`ms' /usr/lib/ruby/1.8/benchmark.rb:308:in `realtime’  
/usr/lib/ruby/gems/1.8/gems/activesupport-2.3.8/lib/active\_support/core\_ext/benchmark.rb:17:in  
`ms' /usr/lib/ruby/gems/1.8/gems/actionpack-2.3.8/lib/action_controller/benchmarking.rb:68:in `perform\_action\_without\_rescue’  
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.8/lib/action\_controller/rescue.rb:160:in  
`perform_action_without_flash' /usr/lib/ruby/gems/1.8/gems/actionpack-2.3.8/lib/action_controller/flash.rb:151:in `perform\_action’  
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.8/lib/action\_controller/base.rb:532:in  
`send' /usr/lib/ruby/gems/1.8/gems/actionpack-2.3.8/lib/action_controller/base.rb:532:in `process\_without\_filters’  
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.8/lib/action\_controller/filters.rb:606:in  
`process' /usr/lib/ruby/gems/1.8/gems/actionpack-2.3.8/lib/action_controller/base.rb:391:in `process’  
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.8/lib/action\_controller/base.rb:386:in  
`call' /usr/lib/ruby/gems/1.8/gems/actionpack-2.3.8/lib/action_controller/routing/route_set.rb:438:in `call’  
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.8/lib/action\_controller/dispatcher.rb:87:in  
`dispatch' /usr/lib/ruby/gems/1.8/gems/actionpack-2.3.8/lib/action_controller/dispatcher.rb:121:in `\_call’  
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.8/lib/action\_controller/dispatcher.rb:130  
/usr/lib/ruby/gems/1.8/gems/activerecord-2.3.8/lib/active\_record/query\_cache.rb:29:in  
`call' /usr/lib/ruby/gems/1.8/gems/activerecord-2.3.8/lib/active_record/query_cache.rb:29:in `call’  
/usr/lib/ruby/gems/1.8/gems/activerecord-2.3.8/lib/active\_record/connection\_adapters/abstract/query\_cache.rb:34:in  
`cache' /usr/lib/ruby/gems/1.8/gems/activerecord-2.3.8/lib/active_record/query_cache.rb:9:in `cache’  
/usr/lib/ruby/gems/1.8/gems/activerecord-2.3.8/lib/active\_record/query\_cache.rb:28:in  
`call' /usr/lib/ruby/gems/1.8/gems/activerecord-2.3.8/lib/active_record/connection_adapters/abstract/connection_pool.rb:361:in `call’  
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.8/lib/action\_controller/string\_coercion.rb:25:in  
`call' /usr/lib/ruby/gems/1.8/gems/rack-1.1.0/lib/rack/head.rb:9:in `call’  
/usr/lib/ruby/gems/1.8/gems/rack-1.1.0/lib/rack/methodoverride.rb:24:in  
`call' /usr/lib/ruby/gems/1.8/gems/actionpack-2.3.8/lib/action_controller/params_parser.rb:15:in `call’  
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.8/lib/action\_controller/session/cookie\_store.rb:99:in  
`call' /usr/lib/ruby/gems/1.8/gems/actionpack-2.3.8/lib/action_controller/failsafe.rb:26:in `call’  
/usr/lib/ruby/gems/1.8/gems/rack-1.1.0/lib/rack/lock.rb:11:in `call' /usr/lib/ruby/gems/1.8/gems/rack-1.1.0/lib/rack/lock.rb:11:in `synchronize’  
/usr/lib/ruby/gems/1.8/gems/rack-1.1.0/lib/rack/lock.rb:11:in `call' /usr/lib/ruby/gems/1.8/gems/actionpack-2.3.8/lib/action_controller/dispatcher.rb:114:in `call’  
/usr/lib/ruby/gems/1.8/gems/actionpack-2.3.8/lib/action\_controller/reloader.rb:34:in  
`run' /usr/lib/ruby/gems/1.8/gems/actionpack-2.3.8/lib/action_controller/dispatcher.rb:108:in `call’  
/usr/lib/ruby/gems/1.8/gems/rails-2.3.8/lib/rails/rack/static.rb:31:in  
`call' /usr/lib/ruby/gems/1.8/gems/rack-1.1.0/lib/rack/urlmap.rb:47:in `call’  
/usr/lib/ruby/gems/1.8/gems/rack-1.1.0/lib/rack/urlmap.rb:41:in `each' /usr/lib/ruby/gems/1.8/gems/rack-1.1.0/lib/rack/urlmap.rb:41:in `call’  
/usr/lib/ruby/gems/1.8/gems/rails-2.3.8/lib/rails/rack/log\_tailer.rb:17:in  
`call' /usr/lib/ruby/gems/1.8/gems/rack-1.1.0/lib/rack/content_length.rb:13:in `call’  
/usr/lib/ruby/gems/1.8/gems/rack-1.1.0/lib/rack/handler/webrick.rb:48:in  
`service' /usr/lib/ruby/1.8/webrick/httpserver.rb:104:in `service’  
/usr/lib/ruby/1.8/webrick/httpserver.rb:65:in `run' /usr/lib/ruby/1.8/webrick/server.rb:173:in `start\_thread’  
/usr/lib/ruby/1.8/webrick/server.rb:162:in `start' /usr/lib/ruby/1.8/webrick/server.rb:162:in `start\_thread’  
/usr/lib/ruby/1.8/webrick/server.rb:95:in `start' /usr/lib/ruby/1.8/webrick/server.rb:92:in `each’  
/usr/lib/ruby/1.8/webrick/server.rb:92:in `start' /usr/lib/ruby/1.8/webrick/server.rb:23:in `start’  
/usr/lib/ruby/1.8/webrick/server.rb:82:in `start' /usr/lib/ruby/gems/1.8/gems/rack-1.1.0/lib/rack/handler/webrick.rb:14:in `run’  
/usr/lib/ruby/gems/1.8/gems/rails-2.3.8/lib/commands/server.rb:111  
/usr/local/lib/site\_ruby/1.8/rubygems/custom\_require.rb:31:in  
`gem_original_require' /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:31:in `require’  
script/server:3

disruptive tech wrote:

> Colin L. wrote:
> 
> > On 4 August 2010 09:32, disruptive tech [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:
> > 
> > > ï¿½ ï¿½ ï¿½format.xml ï¿½{ render :xml =\> @usr }
> > > 
> > > You have a nil object when you didn’t expect it!  
> > > You might have expected an instance of Array.  
> > > The error occurred while evaluating nil.map
> > 
> > What happens if, rather than using collection select, you just display  
> > the id and country name for each item in @country list? Doing that  
> > will prove that the data is ok. I presume that the table has a  
> > country\_name column.
> > 
> > Colin
> 
> here is a read-out - the data is there…
> 
> Listing countries
> 
> Country name  
> UK Show Edit Destroy  
> France Show Edit Destroy  
> Germany Show Edit Destroy
> 
> describe countries;  
> ±-------------±-------------±-----±----±--------±---------------+  
> | Field | Type | Null | Key | Default | Extra |  
> ±-------------±-------------±-----±----±--------±---------------+  
> | id | int(11) | NO | PRI | NULL | auto\_increment |  
> | country\_name | varchar(255) | YES | | NULL | |  
> | created\_at | datetime | YES | | NULL | |  
> | updated\_at | datetime | YES | | NULL | |  
> ±-------------±-------------±-----±----±--------±---------------+  
> 4 rows in set (0.00 sec)
> 
> select \* from countries;  
> ±—±-------------±--------------------±--------------------+  
> | id | country\_name | created\_at | updated\_at |  
> ±—±-------------±--------------------±--------------------+  
> | 4 | UK | 2010-08-02 16:37:43 | 2010-08-02 16:37:43 |  
> | 5 | France | 2010-08-02 16:37:51 | 2010-08-02 16:37:51 |  
> | 6 | Germany | 2010-08-04 08:20:03 | 2010-08-04 08:20:03 |  
> ±—±-------------±--------------------±--------------------+  
> 3 rows in set (0.00 sec)

---

<div class="post-metadata">

**Author:** ![disruptive](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/49beb7/32.png) [@disruptive](https://www.ruby-forum.com/u/disruptive)\
**Post date:** [August 4, 2010, 1:13pm UTC](https://www.ruby-forum.com/t/drop-down-menu/192700/9 "2010-08-04T13:13:05Z")

</div>

On 4 August 2010 11:10, Colin L. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> > > the id and country name for each item in @country list? Â Doing that  
> > > UK Â Show Â Edit Â Destroy  
> > > France Â Show Â Edit Â Destroy  
> > > Germany Â Show Â Edit Â Destroy
> 
> Is that from code inserted in the view at the same point as the  
> collection\_select?

You replied showing the trace (but not actually as a reply to this  
post) but did not answer the above question

Colin

---

<div class="post-metadata">

**Author:** ![disruptive](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/49beb7/32.png) [@disruptive](https://www.ruby-forum.com/u/disruptive)\
**Post date:** [August 4, 2010, 3:15pm UTC](https://www.ruby-forum.com/t/drop-down-menu/192700/10 "2010-08-04T15:15:43Z")

</div>

Colin L. wrote:

> On 4 August 2010 11:10, Colin L. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:
> 
> > > > the id and country name for each item in @country list? Â Doing that  
> > > > UK Â Show Â Edit Â Destroy  
> > > > France Â Show Â Edit Â Destroy  
> > > > Germany Â Show Â Edit Â Destroy
> > 
> > Is that from code inserted in the view at the same point as the  
> > collection\_select?
> 
> You replied showing the trace (but not actually as a reply to this  
> post) but did not answer the above question
> 
> Colin

Problem solved, I had not put the @country\_list into the other methods -  
such as the index one. This now worked and I can create a drop down  
populated from the table.

Now I am presuming the select statement will pop the id into the country  
field in my created users table. However I cannot seem to find it in the  
actual data tables.

Plus also how best to validate drop down boxes?

---

<div class="post-metadata">

**Author:** ![disruptive](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/49beb7/32.png) [@disruptive](https://www.ruby-forum.com/u/disruptive)\
**Post date:** [August 4, 2010, 4:50pm UTC](https://www.ruby-forum.com/t/drop-down-menu/192700/11 "2010-08-04T16:50:54Z")

</div>

On 4 August 2010 14:15, disruptive tech [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> > You replied showing the trace (but not actually as a reply to this  
> > post) but did not answer the above question
> > 
> > Colin
> 
> Problem solved, I had not put the @country\_list into the other methods -  
> such as the index one. This now worked and I can create a drop down  
> populated from the table.

Hmm, so the error in new.html.erb was due to the fact that you had not  
populated @country\_list in the controller#index. I think not.

> Now I am presuming the select statement will pop the id into the country  
> field in my created users table. However I cannot seem to find it in the  
> actual data tables.

No idea what you are talking about. All a select does is to allow a  
selection.

> Plus also how best to validate drop down boxes?

Validation is nothing to do with how the data are selected. It is  
purely a verification of the data as it goes into the db via the  
model.

Colin
