-2

When I visit my procedure_list view I get this error: undefined method `encoding' for nil:NilClass

Apparently the source of the error is on line 12, which is the first link_to method:

<table class="table">
<thead>
  <tr>
    <th>List of Procedures</th>

  </tr>
</thead>
<tbody>
  <tr>
    <td><%= link_to "Service 1", pro_show_path(@code => 99281) %></td>
    <td><%= link_to "Service 2", pro_show_path(@code => 99282) %></td>
    <td><%= link_to "Service 3", pro_show_path(@code => 99283) %></td>
  </tr>
</tbody>
</table>

Here is my controller action:

def pro_show
  @procedures = Procedure.where(:code => @code)
end

Everything looks okay to me..not sure what I did wrong..

hey
  • 55
  • 3
  • 2
    Your stack trace will point you to the exact place where the error occurs - please include it. – Max Williams Sep 25 '15 at 12:47
  • 2
    You've asked the [same question yesterday](http://stackoverflow.com/questions/32763008/how-to-assign-a-variable-as-a-route-parameter-in-rails)? – Vucko Sep 25 '15 at 12:49
  • I thought the answer to that question worked, but now it is throwing an error message. – hey Sep 25 '15 at 12:50

1 Answers1

0

I think It should be

<td><%= link_to "Service 1", pro_show_path(code: 99281) %></td>

But it still looks strange

@code looks like undefined variable

@procedures = Procedure.where(:code => @code)

Did you set @code from params[:code]?

Arsen
  • 10,815
  • 2
  • 34
  • 46
  • It gets defined in the link_to doesn't it? – hey Sep 25 '15 at 12:55
  • Both places where I set @code are included in the question, The link_to works now using code: 99281, but throws an uninitialized constant error when clicked. – hey Sep 25 '15 at 13:06