开发者

authlogic require user

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 开发者_StackOverflow社区be logged in to access this page"
            redirect_to new_user_sessions_url
            return false
        end
    end


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜