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

How do I check if things are working? #1

Open
Instrumentry opened this issue Nov 25, 2011 · 1 comment
Open

How do I check if things are working? #1

Instrumentry opened this issue Nov 25, 2011 · 1 comment

Comments

@Instrumentry
Copy link

I have this in my controller create action:

@thing.save!
@thing.stash(session)

What does this actually do? What is "session"? Does it create a cookie?

Sorry I'm a beginner and there is an awful lack of guides to do lazy registration. Your gem seems to be my only hope.

@whilefalse
Copy link
Owner

Hi,

No problem. The 'session' in your code example is a rails helper method - it returns the current session object. There's a nice little guide here - http://rails.nuvvo.com/lesson/6372-action-controller-session

There are number of different ways to store the session, and rails provides a single interface to these. The default will store the session in a cookie, others will use a database or memcached etc.

In your code example, the id of @thing is stored in the curent session, under a key known to the plugin. The idea is then that people can anonymously create things, which are stashed in the session. When the user finally signs up, you can call:

Thing.reparent_all(session, :user_id, just_created_user_id)

Which will associate all the things created anonymously by this one person to their new user account.

Hope that helps.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants