HABTM with multiple select list


Rails mailing list
[email protected]
http://lists.rubyonrails.org/mailman/listinfo/rails

Hi,

Inessa Weiner wrote:

@title.categories << Category.find(@params[:category_ids]) 

.
.
.

Category Mappings:

<% options = options_from_collection_for_select (@categories,
‘name’,‘id’, @category_ids) %>
<%= select_tag(‘categories_ids[]’, options, {:multiple=>true, :size=>7}) %>


I am getting error:
Couldn’t find Category without an ID

I think it should be:
@title.categories = Category.find(params[:categories_ids]) if
params[:categories_ids]

Regards,
Ali


Rails mailing list
[email protected]
http://lists.rubyonrails.org/mailman/listinfo/rails

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs