collection_select problem

Hi, first and foremost sorry if my english is not the best.

I want to choose between somo products in a view.

I have tickets and i wanna add tickets_products.

1)ruby script/generate scaffold ticket_product name:string 2) rake db: migrate 3) Models-> ticket belongs to ticketproducts and ticketproducts has many tickets. 4) I use Sqlite Manager (firefox pluggin) and I added two ticket products with this soft in tickets_products table.

5)I wrote this in new.html.erb (ticket view):

<% form_for(@ticket) do |f| %>

  <table class="product" >     <tr>     <th><%= _('Product') %></th>     <th><%= _('Breakdown') %></th>     <th><%= _('State') %></th>     </tr>     <tr>     <td><%= f.collection_select :ticket_product_id, @ticket_products, :id, :name, :prompt => _("Select product") %></td>     <td><%= f.collection_select :ticket_breakdown_id, @ticket_breakdowns, :id, :title, :prompt => _("Select breakdown") %> </td>     <td><%= f.collection_select :ticket_state_id, @ticket_states, :id, :title, :prompt => _("Select state") %></td>     </tr>   </table>

The error is:

NoMethodError in Tickets#new

Showing tickets/new.html.erb where line #14 raised:

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

Extracted source (around line #14):

11: <th><%= 'Estado del producto' %></th> 12: </tr> 13: <tr> 14: <td><%= f.collection_select :ticket_product_id, @ticket_products, :id, :name, :prompt=> "Seleccione producto" %></td> 15: <td><%= f.text_field :ticket_breakdown_id %> </td> 16: <td><

Sorry,don´t take care this code: <td><%= f.collection_select :ticket_breakdown_id,

@ticket_breakdowns, :id, :title, :prompt => _("Select breakdown") %> </td>     <td><%= f.collection_select :ticket_state_id, @ticket_states, :id, :title, :prompt => _("Select state") %></td>     </tr>

It will be implemented soon as possible but not yet.

Solved.....it is normal....:frowning:

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

tickets_controller.rb def new     @ticket = Ticket.new     @ticket_products= TicketProduct.find(:all, :order =>'name') ## this line finds the tickets product!!!

    respond_to do |format|       format.html # new.html.erb       format.xml { render :xml => @ticket }     end   end

Thanks a lot!!!