# Session in the model

**URL:** <https://www.ruby-forum.com/t/session-in-the-model/172271>\
**Category:** Rails\
**Created:** [July 18, 2009, 7:57am UTC](https://www.ruby-forum.com/t/session-in-the-model/172271 "2009-07-18T07:57:23Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![mekdigital](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/919ad9/32.png) [@mekdigital](https://www.ruby-forum.com/u/mekdigital)\
**Post date:** [July 18, 2009, 7:57am UTC](https://www.ruby-forum.com/t/session-in-the-model/172271/1 "2009-07-18T07:57:23Z")

</div>

Hello,

I needed a couple of session variables to allow a reader of a blog to  
be redirected to the correct URL if the blog name he’s visiting  
(app/:blogname) gets updated;  
Question: is it convenient to pass ‘base’ to the model or would it be  
more efficient to do everything in the controller?

ex. in blog.rb

def self.locate(base)  
if !base.session[:last\_visited\_blog\_id].nil? && base.params[:blog]  
== base.session[:last\_visited\_blog\_seo]  
return Blog.find\_by\_id(base.session[:last\_visited\_blog\_id])  
end  
end

thanks!

---

<div class="post-metadata">

**Author:** ![mekdigital](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/919ad9/32.png) [@mekdigital](https://www.ruby-forum.com/u/mekdigital)\
**Post date:** [July 18, 2009, 1:22pm UTC](https://www.ruby-forum.com/t/session-in-the-model/172271/2 "2009-07-18T13:22:08Z")

</div>

redirection and related stuff is handled inside your controllers.
