# Need help with sessions

**URL:** <https://www.ruby-forum.com/t/need-help-with-sessions/142186>\
**Category:** Rails\
**Created:** [July 4, 2008, 9:14am UTC](https://www.ruby-forum.com/t/need-help-with-sessions/142186 "2008-07-04T09:14:54Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![torso](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/34f0e0/32.png) [@torso](https://www.ruby-forum.com/u/torso)\
**Post date:** [July 4, 2008, 9:14am UTC](https://www.ruby-forum.com/t/need-help-with-sessions/142186/1 "2008-07-04T09:14:54Z")

</div>

Hi

I have to store id information from items table and send it to the  
notes edit.

So I have link

\<%= link\_to “note”, :controller =\> “notes” , :action =\> “new”, :id  
=\>@item %\>  
this should send only id from item table here is the action from items  
controller

def edit  
@categories = Category.find(:all)  
@item = Item.find(params[:id])  
end

Controller from notes is

def new  
session[:item\_id] = @params[:id]  
@note = Note.new

```
respond_to do |format|
  format.html # new.html.erb
  format.xml { render :xml => @note }
end

```

end

I haven’t found solution for the error :

You have a nil object when you didn’t expect it!  
You might have expected an instance of ActiveRecord::Base.  
The error occurred while evaluating nil.[]

Should i change session[:item\_id] = @params[:id] TO session[:item\_id]  
= @item

---

<div class="post-metadata">

**Author:** ![torso](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/34f0e0/32.png) [@torso](https://www.ruby-forum.com/u/torso)\
**Post date:** [July 4, 2008, 9:22am UTC](https://www.ruby-forum.com/t/need-help-with-sessions/142186/2 "2008-07-04T09:22:31Z")

</div>

> def new  
> session[:item\_id] = @params[:id]  
> @note = Note.new

Not entirely sure what you;re doing, but @params doesn’t exist any  
more. It’s just params.

Fred

---

<div class="post-metadata">

**Author:** ![torso](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/34f0e0/32.png) [@torso](https://www.ruby-forum.com/u/torso)\
**Post date:** [July 4, 2008, 9:38am UTC](https://www.ruby-forum.com/t/need-help-with-sessions/142186/3 "2008-07-04T09:38:20Z")

</div>

That was the error, thanks for help…

On 4 heinä, 10:21, Frederick C. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)
