samedi 29 septembre 2018

How to overcome no method error "undefined method "each" for nil:nilclass" in ruby on rails?

I am doing department store automation project in rails for the first time. I am having an error and I don't know how to overcome it, Please help me out

I have taken a screenshot of the error here

Code:

<html>
<head>
<script type="text/javascript">
    function editable( i) {
        document.getElementById("cancel"+i).disabled = false;
        document.getElementById("upd"+i).disabled = false;
        document.getElementById("edit"+i).disabled = true;
        document.getElementById("doorno"+i).readOnly = false;
        document.getElementById("streetName"+i).readOnly = false;
        document.getElementById("landmark"+i).readOnly = false;
        document.getElementById("city"+i).readOnly = false;
        document.getElementById("state"+i).readOnly = false;
        document.getElementById("pincode"+i).readOnly = false;
        document.getElementById("phoneNo"+i).readOnly = false;
        document.getElementById("altphoneNo"+i).readOnly = false;
    }
    function nonedit( i) {
        document.getElementById("cancel"+i).disabled = true;
        document.getElementById("edit"+i).disabled = false;
        document.getElementById("upd"+i).disabled = true;
        document.getElementById("doorno"+i).readOnly = true;
        document.getElementById("streetName"+i).readOnly = true;
        document.getElementById("landmark"+i).readOnly = true;
        document.getElementById("city"+i).readOnly = true;
        document.getElementById("state"+i).readOnly = true;
        document.getElementById("pincode"+i).readOnly = true;
        document.getElementById("phoneNo"+i).readOnly = true;
        document.getElementById("altphoneNo"+i).readOnly = true;
    }
</script>
</head>
<body>
<div class="container">
<form name="searchSupplier" method="get" action="updSupAction">
<center>
    <table style="width:100%">
        <tr>
            <th><b>Supplier Id</b></th>
            <th><b>Supplier Name</b></th>
            <th><b>Supplier Type</b></th>
            <th><b>GSTIN</b></th>
            <th><b>Door No</b></th>
            <th><b>Street Name</b></th>
            <th><b>Landmark</b></th>
            <th><b>City</b></th>
            <th><b>State</b></th>
            <th><b>Pincode</b></th>
            <th><b>Phone Number</b></th>
            <th><b>Alternative Phone Number</b></th>
            <th><b>Options</b></th>
        </tr>

        <% for x in @sup %>
        <tr>
        <td><input type="text" name="Sid" style="color:black;" value="<%= x.Sid %>" readonly></td>
        <td><%= x.Sname %></td>
        <td><%= x.Stype %></td>
        <td><%= x.GSTIN %></td>
        <!--<td>Your name is <input type="text" value="SAM" readonly="readonly" /></td>-->
        <td><font color="blue"><input type="text" id="<%= "doorno#{@count}" %>" name="doorno" value="<%= x.DoorNo %>" readonly></font></td>
        <td><font color="blue"><input type="text" id="<%= "streetName#{@count}" %>" name="streetName" value="<%= x.StreetName %>" readonly></font></td>
        <td><font color="blue"><input type="text" id="<%= "landmark#{@count}" %>" name="landmark" value="<%= x.Landmark %>" readonly></font></td>
        <td><font color="blue"><input type="text" id="<%= "city#{@count}" %>" name="city" value="<%= x.City %>" readonly></font></td>
        <td><font color="blue"><input type="text" id="<%= "state#{@count}" %>" name="state" value="<%= x.State %>" readonly></font></td>
        <td><font color="blue"><input type="text" id="<%= "pincode#{@count}" %>" name="pincode" value="<%= x.Pincode %>" readonly></font></td>
        <td><font color="blue"><input type="text" id="<%= "phoneNo#{@count}" %>" name="phoneNo" value="<%= x.PhoneNo %>" readonly></font></td>
        <TD><font color="blue"><input type="text" id="<%= "altphoneNo#{@count}" %>" name="altphoneNo" value="<%= x.AlternativePhoneNo %>" readonly></font></TD>
        <td>
        <input type="button" class="registerbtn" name="edit" id="<%= "edit#{@count}" %>" value="EDIT" onclick="editable(<%= @count %>)"><br><br>
        <input type="button" class="registerbtn" name="cancel" id="<%= "cancel#{@count}" %>" value="CANCEL" disabled="true" onclick="nonedit(<%= @count %>)"><br><br>
        <button type="submit" class="registerbtn" name="upd" id="<%= "upd#{@count}" %>" disabled="true" value="UPDATE">UPDATE</button>
        </td>
        </tr><p hidden="true">
        <%= @count=@count+1 %></p>
        <% end %>
    </table>
    </form><a href="Supplier">back</a>
</div>
</body>
</html>

Kindly help me in correcting my code and this view page is for showing the data of supplier and updating it.

Aucun commentaire:

Enregistrer un commentaire