Search code examples
ruby-on-railsrubyjrubyjrubyonrails

Strange RoR problem; googlebot gets error, human sees page


I maintain a Ruby-on-Rails website (actually running JRuby 1.5.5, Rails version 2.3.10) and am seeing something fairly strange. A certain controller action is causing an exception in the logs, when accessed by a search engine bot:

ActionView::TemplateError (can't convert nil into String) on line #14 of app/vie
ws/scenarios/show_send_message.rhtml:
11:   <% if ! is_logged_in? %>
12:     <p>Your email (optional, used to contact you if necessary):<br /><%= tex
t_field_tag 'user_email', @user_email || '', :size => 50 %>
13:     <% if ! is_human? %>
14:       <%= show_simple_captcha %>
15:     <% end %>
16:   <% end %>
17:   <p><%= submit_tag 'Send' %>

... However, when I view the page as a human, it works fine. "show_simple_captcha" is a method from a plugin, and it can't return nil.

Does anyone have any idea why RoR would respond differently to a bot than it would to a real browser? I'm not so much looking for the answer to the problem as I am a way to proceed with debugging, but I'll gladly accept the former.


Solution

  • When I tried to view the page, I got 500 too. There's a big chance something is wrong with your code. For example, you expect session or cookie variable to be set, when it's not.