Can anyone help me out with storing a user's location to session to be
used several times by a user during a login ? I need to create a
textbox where the user enters there zip code and then I need to hold
that zip code value in session to be used for several queries
throughout the user's time within the site. I also would like to
return the user's actual town and state after the zip is submitted but
that is of lesser importance. I think I almost have the controller
code but not quite there yet
def store_location
session [:location] = params[:location]
end
I think its close although I am new and not totally sure what it is
doing. The view code I don't even know how to start though and I
assume it is only the controller and the 'store location' view that I
need to code for?
And here is the part of my controller which handles it:
class SessionController < ApplicationController
def new
end
def create
if using_open_id?
open_id_authentication(params[:openid_url])
else
password_authentication(params[:login], params[:password])
end
end
def destroy
# self.current_user.forget_me if logged_in?
cookies.delete :auth_token
reset_session
flash[:notice] = "You have been logged out."
redirect_back_or_default '/'
end
def password_authentication(login, password)
self.current_user = User.authenticate(login, password)
if logged_in?
successful_login
else
failed_login
end
end
OK I think I have the view working, textbox is there
here is my method in the controller:
def store_location
session[:location] = params[:location]
redirect_to :action => 'list'
flash[:notice] = "your location is "
end
so right now you enter a zipcode and it should be storing it to the
session, the redirect keeps me on the same page and the flash notice
seems to work as well. What I would like to do now is add to that
flash notice the actual value I just stored in the hash...something
like ...flash[:notice] = "your location is " + [session value]
can anyone help with the syntax on this?
BTW does that session code look correct for actualy getting the zip
stored in the session? I have not been able to verify yet becasue I
cant get the flash to return it.