# Select Options

**URL:** <https://www.ruby-forum.com/t/select-options/168946>\
**Category:** Ruby\
**Created:** [May 27, 2009, 4:40pm UTC](https://www.ruby-forum.com/t/select-options/168946 "2009-05-27T16:40:31Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rachel\_N](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/13edae/32.png) [@Rachel\_N](https://www.ruby-forum.com/u/Rachel_N)\
**Post date:** [May 27, 2009, 4:40pm UTC](https://www.ruby-forum.com/t/select-options/168946/1 "2009-05-27T16:40:31Z")

</div>

Hello All,

I have some code per View, Controller, Model (below). The issue I have  
is, in the View, I need to pass the category[‘wsc\_uid\_pk’] data returned  
from \<% @list\_service\_categories.each do |category| %\> to the snippit of  
code that calls \<% @list\_web\_serv\_types.each do |servtype| %\> in  
Controller. Can anyone give me a pointer on how to do this? I have  
Googled all day but to no avail and may not be searching the correct  
terms to return the syntax needed.

List\_service\_catgories and list\_web\_serv\_types are both defined in my  
Model and called from my Controller for return to the View.

The backend is Oracle 10g database where I have the stored db package  
with function calls. We have implemented OCI8 to allow our Rails apps  
to “talk” to Oracle.

Example of data currently returned to View from stored DB data:  
Category: Television, Option List: Premium TV, Enhanced TV, Basic TV  
Category: Internet, Option List: Premium TV, Enhanced TV, Basic TV  
(should be Premium Inet, Enhanced Inet, Basic  
Inet)  
Category: Telephone, Option List: Premium TV, Enhanced TV, Basic TV  
(should be Premium Phone, Enhanced Phone, Basic  
Phone)

In my View:

Service \<% @list\_service\_categories.each do |category| %\> \<%= category['wsc\_uid\_pk'] %\> \<%= category['wsc\_description'] %\> \<%= check\_box('internet', 'make\_connection') %\>\</td \<% @list\_web\_serv\_types.each do |servtype| %\> \<%= category['wsc\_uid\_pk'] %\> \<%= servtype['wbt\_description'] %\> \<% end %\> \<% end %\>

In my Controller:  
def list\_services\_available

# some code here…

##############################

wsc\_code = wsc\_description = wsc\_uid\_pk = ‘’  
#RSN 05-23-2009  
@list\_service\_categories = Customer.list\_service\_categories

##############################

wbt\_code = wbt\_description = wbt\_uid\_pk = ‘’  
#RSN 05-23-2009  
@list\_web\_serv\_types =  
Customer.list\_web\_serv\_types(@list\_service\_categories[0][‘wsc\_uid\_pk’])

##############################

# some more code here…

end

In my Model:  
class Customer \< ActiveRecord::Base  
set\_primary\_key “cus\_uid\_pk”  
CustomerID = :cus\_uid\_pk

# some definitions here…

def self.list\_service\_categories  
ActiveRecord::Base.connection.select(“SELECT gdt\_number1  
wsc\_uid\_pk,gdt\_alpha1 wsc\_code, gdt\_alpha2 wsc\_description FROM  
table(service\_availability\_web\_pkg.fn\_get\_service\_cats)”)  
end

def self.list\_web\_serv\_types(wsc\_uid\_pk) # called from customers  
controller  
ActiveRecord::Base.connection.select(“SELECT gdt\_number1  
wbt\_uid\_pk, gdt\_alpha1 wbt\_code, gdt\_alpha2 wbt\_description FROM  
table(service\_availability\_web\_pkg.fn\_get\_web\_service\_type(#{wsc\_uid\_pk}  
))”)  
end

# some more definitions here…

end

Thank you,  
Rachel S Nichol

---

<div class="post-metadata">

**Author:** ![Rachel\_N](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/13edae/32.png) [@Rachel\_N](https://www.ruby-forum.com/u/Rachel_N)\
**Post date:** [May 27, 2009, 4:55pm UTC](https://www.ruby-forum.com/t/select-options/168946/2 "2009-05-27T16:55:31Z")

</div>

Rails questions should be asked on a Rails mailing list. This one is for  
Ruby (the programming language) not Rails (the web framework).

But the term you might want to Google for is “rails helper methods”
