I am getting this error NoMethodError in Admin#add_to_project undefined method `find'' for #<Project:0x249da88> RAILS_ROOT: script/../config/.. Application Trace | Framework Trace | Full Trace /usr/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/ base.rb:1501:in `method_missing'' ./script/../config/../app/controllers/admin_controller.rb:65:in `add_to_project'' The following code: application.rb -------------- private def get_project session[:project_in_progress] ||= Project.new end project_controller.rb --------------------- def new_general @project = get_project @general = GeneralItem.new @general_tab = "current" end # Get the current Project session and # add the current Object to it def add_to_project @project = get_project @project.find(params[:id]) redirect_to(:action => new_license) end new_general.rhtml ----------------- <%= start_form_tag :action => ''add_to_project'', :id => @project %> <p> <label for="time_in">Time in</label> <br/><%= datetime_select (:general, :time_in) %> </p> project.rb ---------- attr_reader :proj_hash # @items is an array to hold session Objects def add_item(items) @proj_hash << items end
Well, I added model :project model :general_item to application.rb But now I get this NoMethodError in Admin#add_to_project You have a nil object when you didn''t expect it! You might have expected an instance of Array. The error occured while evaluating nil.find Here''s the session dump: --- :project_in_progress: &id001 !ruby/object:Project attributes: {} errors: !ruby/object:ActiveRecord::Errors base: *id001 errors: {} general_item: new_record: true flash: !ruby/hash:ActionController::Flash::FlashHash {}
where does the error occur? could you paste the line of code where the nil.find is done On 12/17/05, Scott Phelps <rails-XAtVw6N1wmx8ahKC1EHl5g@public.gmane.org> wrote:> > Well, I added > > model :project > model :general_item > > to application.rb > > But now I get this > > NoMethodError in Admin#add_to_project > > You have a nil object when you didn''t expect it! > You might have expected an instance of Array. > The error occured while evaluating nil.find > > Here''s the session dump: > > --- > :project_in_progress: &id001 !ruby/object:Project > attributes: {} > errors: !ruby/object:ActiveRecord::Errors > base: *id001 > errors: {} > general_item: > new_record: true > flash: !ruby/hash:ActionController::Flash::FlashHash {} > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-- no one, not even the rain, has such small hands. _______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails
as far as i know the table level operations are static methods, not instance methods. @project.find should be Project.find let me know if it helps. On 12/17/05, Cyril Ucron David <cyx.ucron-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > where does the error occur? could you paste the line of code where the > nil.find is done > > > On 12/17/05, Scott Phelps < rails-XAtVw6N1wmx8ahKC1EHl5g@public.gmane.org> wrote: > > > > Well, I added > > > > model :project > > model :general_item > > > > to application.rb > > > > But now I get this > > > > NoMethodError in Admin#add_to_project > > > > You have a nil object when you didn''t expect it! > > You might have expected an instance of Array. > > The error occured while evaluating nil.find > > > > Here''s the session dump: > > > > --- > > :project_in_progress: &id001 !ruby/object:Project > > attributes: {} > > errors: !ruby/object:ActiveRecord::Errors > > base: *id001 > > errors: {} > > general_item: > > new_record: true > > flash: !ruby/hash:ActionController::Flash::FlashHash {} > > _______________________________________________ > > Rails mailing list > > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > > http://lists.rubyonrails.org/mailman/listinfo/rails > > > > > > -- > no one, not even the rain, has such small hands.-- no one, not even the rain, has such small hands. _______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails