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 --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
> def new > session[:item_id] = @params[:id] > @note = Note.newNot entirely sure what you;re doing, but @params doesn''t exist any more. It''s just params. Fred> > 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--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
That was the error, thanks for help... On 4 heinä, 10:21, Frederick Cheung <frederick.che...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > 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 > > > > > 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--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---