Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

activerecord instance stored in session unsaveable #1876

Closed
pwim opened this Issue Jun 28, 2011 · 7 comments

Comments

Projects
None yet
5 participants
@pwim
Copy link
Contributor

pwim commented Jun 28, 2011

When I create a new active record instance, add it to the session, and later retrieve it, the object becomes unsaveable. That is to say I can call save! on it which returns true, despite the object not being serialized to the db. Sample code follows:

before_filter :foo
def foo
  if session[:foo]
    logger.info session[:foo].save!
    logger.info session[:foo].inspect
  else
    session[:foo] = Widget.new
  end    
end

This worked under 3.0, but no longer works in 3.1.RC4.

@franckverrot

This comment has been minimized.

Copy link
Contributor

franckverrot commented Jul 1, 2011

I can't seem to reproduce it with 3.1.rc4. Do you have anything special in the Widget model?

@pwim

This comment has been minimized.

Copy link
Contributor Author

pwim commented Jul 6, 2011

Hmm, that's strange, as even if I create a basic model (rails g model widget), I get this problem.

@hasclass

This comment has been minimized.

Copy link
Contributor

hasclass commented Jul 11, 2011

What session_store are you using?

@pwim

This comment has been minimized.

Copy link
Contributor Author

pwim commented Jul 11, 2011

Cookie Store

@luizcg

This comment has been minimized.

Copy link

luizcg commented Jul 20, 2011

I'm having the same problem.
Rails edge
revision: b6315d5
branch: 3-1-stable

and using cookie store

My sample code

class MainController < ApplicationController
def index
if(params[:create])
session[:locacao] = Locacao.new(:nome=>"bla bla bla")
elsif(params[:save])
session[:locacao].save!
else
render :text=>"nothing!"
end
end
end

@isaacsanders

This comment has been minimized.

Copy link
Contributor

isaacsanders commented Apr 28, 2012

@pwim Is this still an issue?

@pwim

This comment has been minimized.

Copy link
Contributor Author

pwim commented May 7, 2012

I can't reproduce this anymore.

@pwim pwim closed this May 7, 2012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.