I am getting a NoMethodError with undefined method `each’ for nil:NilClass.
Here is my controls_controller.rb:
class ControlsController < ApplicationController
def index
@controls = Control.all
end
end
And here is my index.html.erb file:
<% @controls.each do |control| %>
<%=render control%>
< div class=“control”>
< p class=“content”><%= control.content %>< /p>
< p class=“time”><%= control.created_at %>< /p>
< /div>
<% end %>
Here are the routes I have configured:
get ‘controls/index’
get ‘/controls’=>‘controls#index’
Any help as to why I am getting this error would be greatly appreciated![quote=“michcmart92, post:1, topic:37890, full:true”]
I am getting a NoMethodError with undefined method `each’ for nil:NilClass.
Here is my controls_controller.rb:
class ControlsController < ApplicationController
def index
@controls = Control.all
end
end
And here is my index.html.erb file:
<% @controls.each do |control| %>
<%=render control%>
<%= control.content %>
<%= control.created_at %>
Here are the routes I have configured:
get ‘controls/index’
get ‘/controls’=>‘controls#index’
Any help as to why I am getting this error would be greatly appreciated!
[/quote]