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
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):
@ticket_products, :id, :name, :prompt=> “Seleccione producto” %>
i donÂ´t ubderstand it, because I have two elements in ticket_products
Somebody can help me please??