Here's the output:
Parameters: {"action"=>"confirm", "id"=>"1", "controller"=>"sites"}
User Columns (2.2ms) SHOW FIELDS FROM `users`
User Load (0.3ms) SELECT * FROM `users` WHERE (`users`.`id` = 2) LIMIT 1
School Load (0.3ms) SELECT * FROM `schools` LIMIT 1
Rendering template within layouts/application
Rendering sites/confirm
ActionView::TemplateError (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) on line #4 of app/views/sites/confirm.erb:
1:
2: <%
3: form_for(:site, :url => {:action => :confirm}) do
4: select_tag(:id, options_from_collection_for_select(@confirm, 'id', 'confirm'))
5: end
6: %>
Even when I did: @confirm = Request.find(:all) in controller, it still returned the error.
Sites Controller:
def confirm
x = current_user.contact.contactable
@confirm = Request.find(:all, :conditions => ["location_id = ?", x])
end
Confirm view in sites folder:
<%
form_for(:site, :url => {:action => :confirm}) do
select_tag(:id, options_from_collection_for_select(@confirm, 'id', 'confirm'))
end
%>
Any idea why? Error occurs on line 4. I believe it thinks @confirm is not an array, although it should be because in controller I pass two items from table into it. I made the options_from_collection_for_select options similar to the one in the rails guide. Basically, I want to show a list of options to select from based on whether those options match the location of the current user. Thanks for any suggestions.