Select Options


#1

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


#2

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”