# Accessing session data

**URL:** <https://www.ruby-forum.com/t/accessing-session-data/131096>\
**Category:** Rails\
**Created:** [March 6, 2008, 12:13am UTC](https://www.ruby-forum.com/t/accessing-session-data/131096 "2008-03-06T00:13:55Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![jimmygoogle](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/c67d28/32.png) [@jimmygoogle](https://www.ruby-forum.com/u/jimmygoogle)\
**Post date:** [March 6, 2008, 12:13am UTC](https://www.ruby-forum.com/t/accessing-session-data/131096/1 "2008-03-06T00:13:55Z")

</div>

I am new to ROR and I am trying to retrieve data based on a session  
value I store. This is a basic app that collects user data and puts  
it in the DB. I then store the last insert id to a session variable  
on the server. This much works. The problem I am having is if that  
user comes back to the site I dont want to show them another form I  
want to show them the data they entered and I want to access the data  
in the DB via the ID I store. I have played with a bunch of different  
things but no go. Anyone have any ideas?

I get the error :  
You have a nil object when you didn’t expect it!  
The error occurred while evaluating nil.order\_number

I am trying to do this in my controller (the else condition works  
fine)

def show

if session[:id]  
@something = SOMETHING.find(session[:id])  
else  
@something = SOMETHING.find(params[:id])  
end

end

My show.rhtml is simply :

\<% for column in SOMETHING.content\_columns %\>

**\<%= column.human\_name %\>:** \<%=h @something.send(column.name) %\>

\<% end %\>
