In my view I have a collection_select. I want it to prompt the user to select if the session variable is set to 0. The else works fine but if the condition is 0 then it is telling me that there is no method 'id'.
- if session[:ptype_id] == 0
= collection_select :ptype, :id, Ptype.all.order(:part_type), :id, :part_type, {:prompt => "Select Type"}, :onchange => "ptype_set(value)"
- else
= collection_select :ptype, :id, Ptype.all.order(:part_type), :id, :part_type, {:selected => session[:ptype_id]}, :onchange => "ptype_set(value)"
The error...
undefined method `id' for #<Ptype::ActiveRecord_Relation:0x007f9bcf138428>