Ayer implementamos un metodo para deshabilitar las sesiones de los
robots, la informacion la sacamos del libro Rails way, es basicamente
esto:
Tras ojear este articulo del mismo Obie:
Me cree mi propia linea de codigo con una recopilacion de robots:
class ApplicationController < ActionController::Base
Explorar el log para mas robots
session :off, :if => lambda {|req| req.user_agent =
~/(Google|msnbot|twiceler|alexa|Sapphire|Gigabot|speedy_spider|Yandex|Yanga|Jeeves|Baidu|bot|SiteUptime|Slurp|WordPress|ZIBB|ZyBorg)/i}
Ayer funciono a las mil maravillas y en el servidor esta funcionando sin
problemas. Pero hoy tras haber estado un tiempo recopilando informacion
sobre otros temas y problemas que tenemos me he llevado una sorpresa al
que rer imiciar el localhost. El problema lo da la linea de codigo que
deshabilita las sesiones para los robots. Os muestro lo que aparece en
el log:
Rendering
/opt/local/lib/ruby/gems/1.8/gems/actionpack-2.1.2/lib/action_controller/templates/rescues/layout.erb
(method_not_allowed)
/!\ FAILSAFE /!\ mié, 06 may 2009 12:14:42 +0200
Status: 500 Internal Server Error
undefined method user_agent=' for #<ActionController::CgiRequest:0x4a1d87c> /opt/local/lib/ruby/gems/1.8/gems/actionpack-2.1.2/lib/action_controller/cgi_process.rb:149:in
method_missing’
/Users/jose/rankia/app/controllers/application.rb:52
/opt/local/lib/ruby/gems/1.8/gems/actionpack-2.1.2/lib/action_controller/session_management.rb:107:in
call' /opt/local/lib/ruby/gems/1.8/gems/actionpack-2.1.2/lib/action_controller/session_management.rb:107:in
session_options_for’
/opt/local/lib/ruby/gems/1.8/gems/actionpack-2.1.2/lib/action_controller/session_management.rb:106:in
each' /opt/local/lib/ruby/gems/1.8/gems/actionpack-2.1.2/lib/action_controller/session_management.rb:106:in
session_options_for’
/opt/local/lib/ruby/gems/1.8/gems/actionpack-2.1.2/lib/action_controller/session_management.rb:135:in
set_session_options_without_components' /opt/local/lib/ruby/gems/1.8/gems/actionpack-2.1.2/lib/action_controller/components.rb:158:in
set_session_options’
/opt/local/lib/ruby/gems/1.8/gems/actionpack-2.1.2/lib/action_controller/session_management.rb:129:in
process' /opt/local/lib/ruby/gems/1.8/gems/actionpack-2.1.2/lib/action_controller/base.rb:389:in
process’
/opt/local/lib/ruby/gems/1.8/gems/actionpack-2.1.2/lib/action_controller/dispatcher.rb:149:in
handle_request' /opt/local/lib/ruby/gems/1.8/gems/actionpack-2.1.2/lib/action_controller/dispatcher.rb:107:in
dispatch’
/opt/local/lib/ruby/gems/1.8/gems/actionpack-2.1.2/lib/action_controller/dispatcher.rb:104:in
synchronize' /opt/local/lib/ruby/gems/1.8/gems/actionpack-2.1.2/lib/action_controller/dispatcher.rb:104:in
dispatch’
/opt/local/lib/ruby/gems/1.8/gems/actionpack-2.1.2/lib/action_controller/dispatcher.rb:120:in
dispatch_cgi' /opt/local/lib/ruby/gems/1.8/gems/actionpack-2.1.2/lib/action_controller/dispatcher.rb:35:in
dispatch’
/opt/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/…/lib/mongrel/rails.rb:76:in
process' /opt/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel/rails.rb:74:in
synchronize’
/opt/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/…/lib/mongrel/rails.rb:74:in
process' /opt/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel.rb:159:in
orig_process_client’
/opt/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/…/lib/mongrel.rb:158:in
each' /opt/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel.rb:158:in
orig_process_client’
/Users/jose/rankia/vendor/plugins/spawn/lib/patches.rb:53:in
process_client' /opt/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel.rb:285:in
run’
/opt/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/…/lib/mongrel.rb:285:in
initialize' /opt/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel.rb:285:in
new’
/opt/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/…/lib/mongrel.rb:285:in
run' /opt/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel.rb:268:in
initialize’
/opt/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/…/lib/mongrel.rb:268:in
new' /opt/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel.rb:268:in
run’
/opt/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/…/lib/mongrel/configurator.rb:282:in
run' /opt/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel/configurator.rb:281:in
each’
/opt/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/…/lib/mongrel/configurator.rb:281:in
run' /opt/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/mongrel_rails:128:in
run’
/opt/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/…/lib/mongrel/command.rb:212:in
run' /opt/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/mongrel_rails:281 /opt/local/bin/mongrel_rails:19:in
load’
/opt/local/bin/mongrel_rails:19
Si comento la linea en cuestion localhost se inicia sin problemas, pero
claro esta subido al servidor y funciona sin problemas…alguien sabe
porque puede ser?