I have a simple controller doing a search on the Twitter. My search works fine from the rails console, but I’m getting a stack overflow error when I run this and can’t figure out what’s going on. My log file shows the index method running over and over.
Controller
class TimelinesController < ApplicationController
def index
@timelines = Twitter.search("Ford Edge", :rpp => 3, :result_type => "recent")
respond_to do |format|
format.html index.html.erb
format.json { render json: @timelines }
end
end
end
View
<% @timelines.each do |timeline| %>
<tr>
<td><%= timeline.from_user %></td>
<td><%= timeline.text %></td>
</tr>
<% end %>
Appreciate any thoughts. Thanks.
I think this is the offending line:
format.html index.html.erbindex.html.erbis not in quotes so it looks like a sequence of method calls to ruby, The first of which isindex, which is causing the infinite recursion.Rails should render the right template for you when you call
format.htmlwithout an argument, and if not, make sure to wrap the template name in quotes.