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| %>

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

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:

<%= ‘Estado del producto’ %>
12:
13:
14: <%= f.collection_select :ticket_product_id,
@ticket_products, :id, :name, :prompt=> “Seleccione producto” %>
15: <%= f.text_field :ticket_breakdown_id %>
16: <

i don´t ubderstand it, because I have two elements in ticket_products

Somebody can help me please??

Sorry,don´t take care this code:

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

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!!!