accessing session data for database

J

jimmygoogle

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. Also when I look at the session data on
the server I see my ID there.

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 %>
<p>
<b><%= column.human_name %>:</b> <%=h @something.send(column.name)
%>
</p>
<% end %>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,262
Messages
2,571,056
Members
48,769
Latest member
Clifft

Latest Threads

Top