Question

I use authlogic for authentication and certain actions require a logged in user, which is controlled via a before_filter like the following. I also use friendly_id on the User model and internally everything there is a look up on the User model there are queries to the friendly_id slug table too. This results in at least 3 queries for certain page view and this happens quite often.

Is there a way to maintain this functionality without running these queries everytime?

I also use memcached as an object store. Is that a possiblity? does it work well with authlogic?

def require_user
        unless current_user
            store_location
            flash[:notice] = "You must be logged in to access this page"
            redirect_to new_user_sessions_url
            return false
        end
    end
Was it helpful?

Solution

I wouldn't worry about it too much. Rails is pretty smart and will cache the query's so basically it will only run it once. Keep an eye on your log files and see if you can find the queries in question, most likely they will have (cache) prepended suggestion that the query results were still in cache.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top