Hey,
I'm designing an app which displays the events near a user in RoR. I'm using the beat forum to facilitate user management/sessions/etc. I've edited the sessions table in the Beast database to contain a "session_location" value and what I'd like to do is to set this to the users location when they log in. This would allow them to change their location for a session whilst not changing the value in their settings.
I know that I have to set this value when a session is created but I'm baffled about how (and where exactly) I have to do it. The following code is used when creating a session:
class SessionsController < ApplicationController def create if using_open_id? cookies[:use_open_id] = {:value => '1', :expires => 1.year.from_now.utc} open_id_authentication else cookies[:use_open_id] = {:value => '0', :expires => 1.year.ago.utc} password_authentication params[:login], params[:password] end end
protected def open_id_authentication authenticate_with_open_id params[:openid_url] do |result, openid_url| if result.successful? if self.current_user = User.find_by_openid_url(openid_url) successful_login else failed_login "Sorry, no user by the identity URL {openid_url} exists"[:openid_no_user_message, openid_url.inspect] end else failed_login result.message end end end
def password_authentication(name, password) if self.current_user = User.authenticate(name, password) successful_login else failed_login "Invalid login or password, try again please."[:invalid_login_message] end end
def successful_login cookies[:login_token] = {:value => "#{current_user.id};#{current_user.active_login_key}", :expires => 1.year.from_now.utc} if params[:remember_me] == "1" redirect_to CGI.unescape(params[:to] || home_path) end end
If anyone could help, I'd really appreciate it.