To preface this I am a complete Rails newcomer so don't judge my lack of skills too harshly. Anyway, my rails app is throwing this error:
Called id for nil, which would mistakenly be 4 -- if you really wanted the id of nil, use object_id
I am trying to make a basic form that will allow a user to search for a "match" by "country". It is just a proof of concept as I am still learning.
Here is my model:
class OmMatch < ActiveRecord::Base
end
Here is my controller:
class OmMatchesController < ApplicationController
def search
@search = OmMatch.search(params[:search])
@match = @search.all
end
end
Here is the view:
<html>
<head><title>"Matches"</title></head>
<body>
<% form_for @search do |f| %>
<p>
<%= f.label :country_equals, "Country" %><br />
<%= f.text_field :country_equals %>
</p>
<p>
<%= f.submit "Submit" %>
</p>
<% end %>
<table>
<tr>
<th>"Match Name"</th>
<th>"Country"</th>
</tr>
<% @match.each do |match| %>
<tr>
<td><%=h match.matchname %></td>
<td><%=h match.country %></td>
</tr>
<% end %>
<table>
</body>
</html>
I believe that the problem is from search not being initialized but I am not sure how to that.
Thanks