0

I am working on an application that will ultimately help my company move to a universal registration/activation process to help support a multitude of products. Upon a new user registration or activation (using a group code) the "single" system branding is needing to change based on where they came from.

Right now, I have it setup where a client_id param is passed in the URL and then the @client is setup by doing an ActiveRecord Find By to set the current client.

I am needing to set it up so that it sets the client information in a session. But I am having issues with getting that to work.

Here is my ApplicationController

class ApplicationController < ActionController::Base
  protect_from_forgery 
  before_filter :set_client_id
  helper_method :brand

   def set_client_id
     session[:client_id] ||= params[:client_id]
   end

  def brand
    @brand = Client.find_by_app_id(session[:client_id])
  end
end

One of the issues I keep running into is if someone comes back into the site with a different client_id param, the old one is kept in session.

How could I rewrite the above to simply always just set the client_id in session even if the client_id param changes?

dennismonsewicz
  • 25,132
  • 33
  • 116
  • 189

0 Answers0