This works for me in Rails 3
<%= form_for … do |form| %>
<%= form.collection_select(:category_id, Category.all, :id,
:category_type)
%>
I am not super familiar with HAML, but I googled github haml
collection_select and the code examples that I saw seem consistent with
what I am offering…
collection_select prototype from
collection_select(object, method, collection, value_method, text_method,
options = {}, html_options = {})
Returns and tags for the collection of existing return
values of method for object’s class. The value returned from calling
method
on the instance object will be selected. If calling method returns nil,
no
selection is made without including :prompt or :include_blank in the
options hash.
The :value_method and :text_method parameters are methods to be called
on
each member of collection. The return values are used as the value
attribute and contents of each tag, respectively. They can also
be
any object that responds to call, such as a proc, that will be called
for
each member of the collection to retrieve the value/text.
Rewrite:
= form_for … do |form|
= form.collection_select(nil, :category_id, Category.all, :id, :name,
{:include_blank => true}, {:style => “width:300px”})
## I think that you may omit nil as the object, maybe your object
here
is @package??
= form.collection_select(nil, :sub_category_id,
@package.category.sub_categories.all, :id, :name, {:include_blank =>
false}, {:style => “width:300px”})
Hope this helps