Rails session gets destroy whenever model destroy link is clicked -
if click destroy on record 3 models models, user gets logged out. i'm using devise , ominauth.
#this logs out user def destroy @rating = rating.find(params[:id]) @rating.destroy end started post "/ratings/29" 192.168.1.103 @ 2011-02-26 20:11:45 +0000 processing ratingscontroller#destroy html parameters: {"id"=>"29"} user load (0.5ms) select `users`.* `users` `users`.`id` = 2 limit 1 rating load (0.3ms) select `ratings`.* `ratings` `ratings`.`id` = 29 limit 1 sql (0.0ms) begin arel (0.5ms) delete `ratings` `ratings`.`id` = 29 sql (2.7ms) commit request parameters: none show session dump session_id: "16a92c418fdfa8966b60b09e76346443" show env dump gateway_interface: "cgi/1.1" http_accept: "application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5" http_accept_charset: "iso-8859-1,utf-8;q=0.7,*;q=0.3" http_accept_encoding: "gzip,deflate,sdch" http_accept_language: "en-us,en;q=0.8" http_cache_control: "max-age=0" http_connection: "keep-alive" http_cookie: "_traitly_session=bah7bkkid3nlc3npb25fawqgogzfriilmtk5ndexyjnjmwmzy2u1nwiwzdnjyjg2y2fimgninzy%3d--4c140502f8a075f61742fdf11e6fc7100722ca14" http_host: "192.168.1.105:3000" http_if_none_match: "\"2d7f4ba60c47e0cf39f1361e2274fa89\"" http_referer: "http://192.168.1.105:3000/subjects" http_user_agent: "mozilla/5.0 (x11; u; linux x86_64; en-us) applewebkit/534.16 (khtml, gecko) chrome/10.0.648.82 safari/534.16" http_version: "http/1.1" path_info: "/subjects" query_string: "" remote_addr: "192.168.1.103" remote_host: "192.168.1.103" request_method: "get" request_path: "/" request_uri: "http://192.168.1.105:3000/subjects" script_name: "" server_name: "192.168.1.105" server_port: "3000" server_protocol: "http/1.1" server_software: "webrick/1.3.1 (ruby/1.9.2/2010-12-25)" action_controller.instance: #<subjectscontroller:0x90ecc1c @action_has_layout=true, @view_context_class=nil, @_headers={"content-type"=>"text/html"}, @_status=200, @_response=#<actiondispatch::response:0x90ecb68 ......too long - had cut off action_dispatch.cookies: {"_traitly_session"=>"bah7bkkid3nlc3npb25fawqgogzfriilmtk5ndexyjnjmwmzy2u1nwiwzdnjyjg2y2fimgninzy=--4c140502f8a075f61742fdf11e6fc7100722ca14"} action_dispatch.parameter_filter: [:password, :password, :password_confirmation] action_dispatch.remote_ip: 192.168.1.103 action_dispatch.request.content_type: nil action_dispatch.request.formats: [text/html] action_dispatch.request.parameters: {"action"=>"index", "controller"=>"subjects"} action_dispatch.request.path_parameters: {:action=>"index", :controller=>"subjects"} action_dispatch.request.query_parameters: {} action_dispatch.request.request_parameters: {} action_dispatch.request.unsigned_session_cookie: {"session_id"=>"199411b3c1c3ce55b0d3cb86cab0cb76"} action_dispatch.secret_token: "b3dc65e5cc9d1af31fb06160a604132f5a1f4d13edc313d74cb1bfd7e63994d429f6e8032669ea26ff4a8dab66b79f6070f8449b4a422a7862bb4307a4d84416" rack.errors: #<io:<stderr>> rack.input: #<stringio:0x913578c> rack.multiprocess: false rack.multithread: false rack.request.cookie_hash: {"_traitly_session"=>"bah7bkkid3nlc3npb25fawqgogzfriilmtk5ndexyjnjmwmzy2u1nwiwzdnjyjg2y2fimgninzy=--4c140502f8a075f61742fdf11e6fc7100722ca14"} rack.request.cookie_string: "_traitly_session=bah7bkkid3nlc3npb25fawqgogzfriilmtk5ndexyjnjmwmzy2u1nwiwzdnjyjg2y2fimgninzy%3d--4c140502f8a075f61742fdf11e6fc7100722ca14" rack.request.query_hash: {} rack.request.query_string: "" rack.run_once: false rack.session: {"session_id"=>"199411b3c1c3ce55b0d3cb86cab0cb76"} rack.session.options: {:path=>"/", :domain=>nil, :expire_after=>nil, :secure=>false, :httponly=>true, :id=>"199411b3c1c3ce55b0d3cb86cab0cb76"} rack.url_scheme: "http" rack.version: [1, 1] warden: #<warden::proxy:0x9133bf8 @winning_strategies={}, @users={:user=>nil}, @env={"gateway_interface"=>"cgi/1.1", "path_info"=>"/subjects", "query_string"=>"", "remote_addr"=>"192.168.1.103", "remote_host"=>"192.168.1.103", "request_method"=>"get", "request_uri"=>"http://192.168.1.105:3000/subjects", "script_name"=>"", "server_name"=>"192.168.1.105", "server_port"=>"3000", "server_protocol"=>"http/1.1", "server_software"=>"webrick/1.3.1 (ruby/1.9.2/2010-12-25)", "http_host"=>"192.168.1.105:3000", "http_connection"=>"keep-alive", "http_referer"=>"http://192.168.1.105:3000/subjects", "http_cache_control"=>"max-age=0", "http_user_agent"=>"mozilla/5.0 (x11; u; linux x86_64; en-us) applewebkit/534.16 (khtml, gecko) chrome/10.0.648.82 safari/534.16", "http_accept"=>"application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5", "http_accept_encoding"=>"gzip,deflate,sdch", "http_accept_language"=>"en-us,en;q=0.8", "http_accept_charset"=>"iso-8859-1,utf-8;q=0.7,*;q=0.3", "http_cookie"=>"_traitly_session=bah7bkkid3nlc3npb25fawqgogzfriilmtk5ndexyjnjmwmzy2u1nwiwzdnjyjg2y2fimgninzy%3d--4c140502f8a075f61742fdf11e6fc7100722ca14", "http_if_none_match"=>"\"2d7f4ba60c47e0cf39f1361e2274fa89\"", "rack.version"=>[1, 1], "rack.input"=>#<stringio:0x913578c>, "rack.errors"=>#<io:<stderr>>, "rack.multithread"=>false, "rack.multiprocess"=>false, "rack.run_once"=>false, "rack.url_scheme"=>"http", "http_version"=>"http/1.1", "request_path"=>"/", "action_dispatch.parameter_filter"=>[:password, :password, :password_confirmation], "action_dispatch.secret_token"=>"b3dc65e5cc9d1af31fb06160a604132f5a1f4d13edc313d74cb1bfd7e63994d429f6e8032669ea26ff4a8dab66b79f6070f8449b4a422a7862bb4307a4d84416", "action_dispatch.remote_ip"=>192.168.1.103, "rack.session"=>{"session_id"=>"199411b3c1c3ce55b0d3cb86cab0cb76"}, "rack.session.options"=>{:path=>"/", :domain=>nil, :expire_after=>nil, :secure=>false, :httponly=>true, :id=>"199411b3c1c3ce55b0d3cb86cab0cb76"}, "rack.request.cookie_string"=>"_traitly_session=bah7bkkid3nlc3npb25fawqgogzfriilmtk5ndexyjnjmwmzy2u1nwiwzdnjyjg2y2fimgninzy%3d--4c140502f8a075f61742fdf11e6fc7100722ca14", "rack.request.cookie_hash"=>{"_traitly_session"=>"bah7bkkid3nlc3npb25fawqgogzfriilmtk5ndexyjnjmwmzy2u1nwiwzdnjyjg2y2fimgninzy=--4c140502f8a075f61742fdf11e6fc7100722ca14"}, "action_dispatch.cookies"=>{"_traitly_session"=>"bah7bkkid3nlc3npb25fawqgogzfriilmtk5ndexyjnjmwmzy2u1nwiwzdnjyjg2y2fimgninzy=--4c140502f8a075f61742fdf11e6fc7100722ca14"}, "action_dispatch.request.unsigned_session_cookie"=>{"session_id"=>"199411b3c1c3ce55b0d3cb86cab0cb76"}, "warden"=>#<warden::proxy:0x9133bf8 ...>, "action_dispatch.request.path_parameters"=>{:action=>"index", :controller=>"subjects"}, "action_controller.instance"=>#<subjectscontroller:0x90ecc1c @action_has_layout=true, @view_context_class=nil, @_headers={"content-type"=>"text/html"}, @_status=200, @_response=#<actiondispatch::response:0x90ecb68 @writer=#<proc:0x90ecaf0@/usr/local/rvm/gems/ruby-1.9.2-p136@traitly/gems/actionpack-3.0.4/lib/action_dispatch/http/response.rb:43 (lambda)>, @block=nil, @length=0, @header={}, @status=200, @body=[], @cookie=[], @sending_file=false, @blank=false, @cache_control={}, @etag=nil, @request=#<actiondispatch::request:0x90ecb7c @env={...}, @fullpath="/subjects", @request_method="get", @filtered_parameters={"action"=>"index", "controller"=>"subjects"}, @method="get">>, @_request=#<actiondispatch::request:0x90ecb7c @env={...}, @fullpath="/subjects", @request_method="get", @filtered_parameters={"action"=>"index", "controller"=>"subjects"}, @method="get">, @_env={...}, @lookup_context=#<actionview::lookupcontext:0x90ec4c4 @details_key=nil, @details={:handlers=>[:erb, :rjs, :builder, :rhtml, :rxml], :formats=>[:html], :locale=>[:en, :en]}, @skip_default_locale=false, @frozen_formats=false, @view_paths=[/root/projects/traitly/app/views, /usr/local/rvm/gems/ruby-1.9.2-p136@traitly/gems/devise-1.1.7/app/views]>, @_action_name="index", @_response_body=nil, @_config={}, @current_user=nil>, "action_dispatch.request.content_type"=>nil, "action_dispatch.request.request_parameters"=>{}, "rack.request.query_string"=>"", "rack.request.query_hash"=>{}, "action_dispatch.request.query_parameters"=>{}, "action_dispatch.request.parameters"=>{"action"=>"index", "controller"=>"subjects"}, "action_dispatch.request.formats"=>[t
you're using rails 3, uses javascript issue delete requests. because request isn't set properly, log showing started post
instead of correct started delete
.
the request not include required csrf data, , of rails 3.0.4 session silently reset instead of throwing actioncontroller::invalidauthenticitytoken
error. why suspect authentication issue lies devise, being triggered within rails itself.
to fix include following in layout:
<%= javascript_include_tag :defaults %> <%= csrf_meta_tag %>
also ensure have updated rails.js (which contains javascript code used delete requests). rails 3.0.4 upgrade notes explain issue in more detail.
if you're using jquery rails.js replacement, can updated version from here.
Comments
Post a Comment