Need help with sessions

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

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

That was the error, thanks for help…

On 4 heinä, 10:21, Frederick C. [email protected]

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs