This might be simple but I'm starting out with rails.
I have the following statement:
@subjects = Cartitem.find_by_cid(session[:customerid])
In my View I have some code like this:
<% @subjects.each do |d| %>
<tbody>
<tr>
All works when when the above query returns multiple rows. However, when above query returns only one row then I get an error in my View saying method each
is not defined.
What is the way to avoid this? Do I need to have some if/else
in my view?